Need a onclick Script

9 replies
I need a onclick script for my site, i want that when somebody click on my page a new site get open in new window.
#onclick #script
  • Profile picture of the author geekSoftware
    HTML Code:
    <html>
            <head>
    	        <title>Simple OnClick Script</title>
            </head>
            <body>
                    Please click...
    
    
                    <script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
                    <script type="text/javascript">
    	                $("body").on("click", function() {
    		                window.open("https://kindlebookspromotion.com", "_blank");
    	                });
                    </script>
            </body>
    </html>
    {{ DiscussionBoard.errors[9756161].message }}
    • Profile picture of the author BDazzler
      Originally Posted by geekSoftware View Post

      HTML Code:
      <html>
              <head>
                  <title>Simple OnClick Script</title>
              </head>
              <body>
                      Please click...
      
      
                      <script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
                      <script type="text/javascript">
                          $("body").on("click", function() {
                              window.open("https://kindlebookspromotion.com", "_blank");
                          });
                      </script>
              </body>
      </html>
      Yeah, that's pretty much it. I would have put the jQuery load in the html head, but that does what the OP asks.
      {{ DiscussionBoard.errors[9756516].message }}
      • Profile picture of the author xerious
        Originally Posted by BDazzler View Post

        Yeah, that's pretty much it. I would have put the jQuery load in the html head, but that does what the OP asks.

        The best way to implement is put the jquery on bottom and put, you page will load first and last jquery will load, the effect will be the same, but your seo score will be a bit higher.
        And the user experience goes up

        $(document).ready(function(){
        $("body").on("click", function() {
        window.open("https://kindlebookspromotion.com", "_blank");
        });
        });
        {{ DiscussionBoard.errors[9756650].message }}
      • Profile picture of the author navi009
        Guys, i need one improvement in this script, i wanna visitors to remain on my site,
        now what happened when visitors click on my site a new windows open and they automatically leave my site.
        {{ DiscussionBoard.errors[9762728].message }}
        • Profile picture of the author kilgore
          Why not just do something like this?

          Code:
          <a href="http://www.example.com" target="_blank">Link text</a>
          Edit You'll see a rel="nofollow" above which WF is apparently adding automatically. You can include (or exclude) that part as you see fit.
          {{ DiscussionBoard.errors[9762832].message }}
          • Profile picture of the author navi009
            Thanks for reply, but i need a onclick window and visitors remain on my site.
            {{ DiscussionBoard.errors[9769227].message }}
  • Profile picture of the author navi009
    Thanks a lot guys, its working perfectly, now i hope i will earn some extra money too.
    {{ DiscussionBoard.errors[9760219].message }}
  • Profile picture of the author navi009
    xerious thanks for your valuable advice.
    {{ DiscussionBoard.errors[9760222].message }}
  • Profile picture of the author navi009
    Guys, i need one improvement in this script, i wanna visitors to remain on my site,
    now what happened when visitors click on my site a new windows open and they automatically leave my site.
    {{ DiscussionBoard.errors[9760255].message }}

Trending Topics