Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Need a onclick Script (https://www.warriorforum.com/programming/1028144-need-onclick-script.html)

navi009 20th December 2014 02:29 AM

Need a onclick Script
 
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.

geekSoftware 20th December 2014 06:04 AM

Re: Need a onclick Script
 
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>


BDazzler 20th December 2014 10:16 AM

Re: Need a onclick Script
 
Quote:

Originally Posted by geekSoftware (Post 9756161)
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.

xerious 20th December 2014 11:38 AM

Re: Need a onclick Script
 
Quote:

Originally Posted by BDazzler (Post 9756516)
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");
});
});

navi009 22nd December 2014 02:22 AM

Re: Need a onclick Script
 
Thanks a lot guys, its working perfectly, now i hope i will earn some extra money too.

navi009 22nd December 2014 02:24 AM

Re: Need a onclick Script
 
xerious thanks for your valuable advice.

navi009 22nd December 2014 02:40 AM

Re: Need a onclick Script
 
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.

navi009 22nd December 2014 11:14 PM

Re: Need a onclick Script
 
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.

kilgore 23rd December 2014 12:23 AM

Re: Need a onclick Script
 
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.

navi009 26th December 2014 12:37 PM

Re: Need a onclick Script
 
Thanks for reply, but i need a onclick window and visitors remain on my site.


All times are GMT -6. The time now is 07:30 PM.