Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Java Script Code That Triggers Open In New Window  (Read 10722 times)

0 Members and 1 Guest are viewing this topic.

lina19



    Rookie

    • Experience: Beginner
    • OS: Unknown
    Re: Java Script Code That Triggers Open In New Window
    « Reply #15 on: January 09, 2012, 04:48:56 PM »
    or u working with only javascript??you cant do the "ip" part with javascript+ database...


    u will need to add all your ips in a database/textfile by using php(server side)...
    whenever a new person comes...validate this new ip with your exisiting database value..
    if it is not seen in the database, open page

    in php u have a function known as header( instead of window.location...something like this i forgot exactly....

    else u can do this in javascript,

    var [] array_list="<?php echo $array_list ?>";

    var new_ip="<?php echo $newip ?>";

    for (int i=0;i<array_list.length; i++)
    {
     


    lina19



      Rookie

      • Experience: Beginner
      • OS: Unknown
      Re: Java Script Code That Triggers Open In New Window
      « Reply #16 on: January 09, 2012, 04:52:50 PM »
      for (int i=0;i<array_list.length; i++)
      {
          if (array_list.equals(new_ip))
         { window.location="a.html";
        }
      }

      sry...i havent worked with php nor javascript for one year...i have forgotten about the syntax...but the logic is here....and i guess u can understand it as ur a programmer as well....


      u can use ajax as well to do it....

      u cant extract ip from javascript....its impossible...

      u can use java like applets to extract ip as well...

      roco

        Topic Starter


        Rookie

        Re: Java Script Code That Triggers Open In New Window
        « Reply #17 on: January 09, 2012, 05:25:56 PM »
        That is quite ok..You have helped me a great deal!! I wish I was a programmer lol,but I am learning as I go along. Thanks again for your help!!

        kpac

        • Web moderator
        • Moderator


        • Hacker

        • kpac®
        • Thanked: 184
          • Yes
          • Yes
          • Yes
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 7
        Re: Java Script Code That Triggers Open In New Window
        « Reply #18 on: January 10, 2012, 12:01:20 PM »
        Lina, please use the CODE tag when displaying code in your posts...

        Code: [Select]
        // like this

        Code: [Select]
        window.location = "URL HERE";
        This just sends the user to a new URL in the same window they are currently looking at.

        Code: [Select]
        window.open("URL HERE", "_blank", "width=300,height=200");
        This opens a new window/tab with the specified URL. You can change the width and height if desired (in pixels).

        Whether a new tab or window opens depends on the browser. I think IE opens new windows, Firefox opens tabs etc....there's no way to specify which one you want (I'm 90% sure).

        To only display it once a day for each visitor is more complicated and involves using cookies to check the last time they visited the site. See Google.

        lina19



          Rookie

          • Experience: Beginner
          • OS: Unknown
          Re: Java Script Code That Triggers Open In New Window
          « Reply #19 on: January 10, 2012, 12:10:56 PM »
          thx kpac...but where is the "code tag"...im not finding anything to help me show my codes...thanks beforehand

          kpac

          • Web moderator
          • Moderator


          • Hacker

          • kpac®
          • Thanked: 184
            • Yes
            • Yes
            • Yes
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 7
          Re: Java Script Code That Triggers Open In New Window
          « Reply #20 on: January 10, 2012, 12:15:48 PM »
          Code: [Select]
          [code ]Code[ /code]

          without the spaces...

          lina19



            Rookie

            • Experience: Beginner
            • OS: Unknown
            Re: Java Script Code That Triggers Open In New Window
            « Reply #21 on: January 10, 2012, 12:27:58 PM »
            Code: [Select]
            test

            lina19



              Rookie

              • Experience: Beginner
              • OS: Unknown
              Re: Java Script Code That Triggers Open In New Window
              « Reply #22 on: January 10, 2012, 12:28:24 PM »
              ok thx