js code for new tab

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    js code for new tab

    Hello, I want js code to open new tab on 2nd click. I have a code. On first click it opens a new tab but after 3 second a new tab automatically opens. I want to open 2nd tab also on click after 3 seconds, not automatically. Here is my code:

    <script>
    $(window).one('click',function() {
    var url = "https://google.com";
    window.open(url, "_blank");
    setTimeout(function(){ window.open(url, "_blank")}, 3000);
    })
    </script>

    #2
    [QUOTE=omshankar;n154803]Hello, I want js code to open new tab on 2nd click. I have a code. On first click it opens a new tab but after 3 second a new tab automatically opens. I want to open 2nd tab also on click after 3 seconds, not automatically. Here is my code:

    Try the following

    Code:
    $(window).one('click',function() {
    var url = "https://google.com";
    [COLOR=#691c97]window[/COLOR].[COLOR=#693a17]open[/COLOR]([COLOR=#0b6125]url[/COLOR],[COLOR=#0b6125]'_blank'[/COLOR]);
    }
    Want something coded email me at sales@webnwaphost.com for a prices.




    Comment


      #3
      [QUOTE=crazybrumi;n154804]
      Originally posted by omshankar View Post
      Hello, I want js code to open new tab on 2nd click. I have a code. On first click it opens a new tab but after 3 second a new tab automatically opens. I want to open 2nd tab also on click after 3 seconds, not automatically. Here is my code:

      Try the following

      Code:
      $(window).one('click',function() {
      var url = "https://google.com";
      [COLOR=#691c97]window[/COLOR].[COLOR=#693a17]open[/COLOR]([COLOR=#0b6125]url[/COLOR],[COLOR=#0b6125]'_blank'[/COLOR]);
      }
      it opens single popup in new tab. I want 2nd popup in new tab on clicking after 3 second. It should not be opened automatically. It should be opened after clicking.

      Comment


        #4
        Something like:
        Code:
        <script>
                    var x = 1;
                    $(window).on('click',function()
                    {    
                        if(x==2)
                        {
                            var url = "https://google.com";
                            window.open(url, "_blank");
                            setTimeout(function(){ window.open(url, "_blank")}, 3000);
                        }
                        x++;
                    })
        </script>

        Comment


          #5
          Originally posted by something else View Post
          Something like:
          Code:
          <script>
          var x = 1;
          $(window).on('click',function()
          {
          if(x==2)
          {
          var url = "https://google.com";
          window.open(url, "_blank");
          setTimeout(function(){ window.open(url, "_blank")}, 3000);
          }
          x++;
          })
          </script>
          This code also opens 2nd popup automatically. 1st popup opens on clicking. but 2nd popup opens automatically. I want 2nd popup should also open on clicking after 3 seconds.

          Comment


            #6
            its not clear what you are after .... Maybe this:

            Code:
            <script>
                        var x = 1;
                        $(window).on('click',function()
                        {    
                            if(x==1)
                            {
                                var url = "https://google.com";
                                setTimeout(function(){ window.open(url, "_blank")}, 3000);
                            }
                            if(x==2)
                            {
                                var secondUrl = "https://google.com";
                                setTimeout(function(){ window.open(secondUrl, "_blank")}, 3000);
                            }
                            x++;
                        })
            </script>
            if this isn't right can you write a process list of what you would like to happen..
            eg:

            page loads..
            first click
            wait 3 seconds
            open popup
            second click
            wait 3 seconds
            open second popup

            Comment


              #7
              Yes, This didn't work properly.
              Process is like this:

              Page loads
              first click
              open popup (due to clicking)
              wait 3 seconds
              second click
              open second popup (due to second click)


              Popups should not open automatically. When I click on the page then due to clicking popup should open. Like pops of adnetworks like propeller, adcash works. i.e when you click on the page then popup opens, not automatically.

              Edit: Even if I wait on that page for more than 3 seconds, popup should not open automatically. When I click after 3 seconds (may be after 20 seconds) then popup should open.
              Last edited by omshankar; 25.07.18, 17:42.

              Comment


                #8
                I think this is what you are after:
                Code:
                <script>
                            var x = 0;
                            $(window).on('click',function()
                            {    
                                if(x==0)
                                {
                
                                    var url = "https://google.com";
                                    window.open(url, "_blank")
                                    x++;
                                    setTimeout(function(){ x++; }, 3000);
                                }
                                if(x==2)
                                {
                                    var secondUrl = "https://google.com";
                                    window.open(secondUrl, "_blank");
                                    x++;
                                }
                            })
                </script>
                Last edited by something else; 25.07.18, 20:23.

                Comment


                  #9
                  Yes this is what I was looking for. Works perfectly. Thanks.

                  Comment

                  Working...
                  X