Friday, April 6, 2012

Creating a Simple Popunder Script

Creating a Simple Popunder Script 

Popunder scripts can be very helpful in certain cases. in this post you will find a fully functional popunder script that can be used at any place as per need.
You can use the below code with some custom adjustments to fit your needs. Below are some useful parameters in the below code:
popunder[0] = "this can be any url or link that you want in popunder."
var width = 'width of your popunder window';
var height = 'height of your popunder window';
var one_time = This is a numerical value that sets the number of popunders per session. putting 0 will open a popunder each time the page is loaded.



Place the below code in between the head area(ie <head>Code here</head>) or the bottom of your webpage before </body></html>.
Code:


<script type="text/javascript">
var popunder=new Array()
popunder[0]="http://codingtrickz.blogspot.com/"
var width = '700';
var height = '100';
var p = 'scrollbars=no,resizable=yes,toolbar=no,' + //these are obvious variables. set "yes" or "no".
'menubar=yes,status=yes,location=no,left=85,top=20,height=' + //the location on the user's screen
height + ',width=' + width;
var one_time=1
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if the cookie exists
offset += search.length
end = document.cookie.indexOf(";", offset); // set the index of beginning value
if (end == -1) // set the index of the end of cookie value
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function loadornot(){
if (get_cookie('popunder')==''){
load_pop_power()
document.cookie="popunder=yes"
}
}
function load_pop_power(){
win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"bw",p)
win2.blur()
window.focus()
}
if (one_time==0)
load_pop_power()
else
loadornot()
</script>

No comments:

Post a Comment