Need help to add a java popunder script to a php index page?

Discussion in 'PHP' started by netnuta, Jul 28, 2008.

  1. #1
    I need to add a java popunder script to a php index page, can some one help with this?

    The script works ok on html and is as follows:

    <head>

    <script type='text/javascript'>
    function doOpen(url)
    {
    if (get_cookie('popunder')==''){
    // attempt to open the popup
    win = window.open(url, 'test', 'toolbar,status,resizable,scrollbars,menubar,location,height=600,width=800');
    if (win)
    {
    // popup successfully created
    win.blur();
    setTimeout('win.focus();',10000);
    } else {
    // popup was not created.
    showPopupMessage(url);
    }
    var today = new Date();
    today.setTime( today.getTime() );
    expires = 1 * 1000 * 60 * 60 * 24;
    var expires_date = new Date( today.getTime() + (expires) );
    document.cookie="popunder=yes;expires=" + expires_date.toGMTString()
    }
    return win;
    }
    function init()
    {
    var win = doOpen('http://www.yoursite.com/');
    }
    function showPopupMessage(url)
    {
    if (!document.createElement)
    {
    return;
    }
    var elmDiv = document.createElement('div');
    if (typeof(elmDiv.innerHTML) != 'string')
    {
    return;
    }
    elmDiv.id = 'popupmessage';
    elmDiv.style.cssText =
    'position: absolute; left: 300px; top: 225px;' +
    'width: 350px;' +
    'color: 000099; ' +
    'background-color: white; ' +
    'font-weight: bold; ' +
    'font-size: 14; ' +
    'border: solid black 2px; ' +
    'padding: 1em;';

    var html = 'Thank you for visiting this-site.com. ' +
    'Please enjoy your stay. ' +
    'Visit back tomorrow for more exciting news! ' +

    '<p align="right">' +
    '<a href="#" ' +
    'onclick="document.cookie=\'popunder=\'; win = doOpen(\'' + url + '\'); hidePopupMessage(); return false;">' +
    'close</a>' +

    '<\/div>';
    document.body.appendChild(elmDiv);
    elmDiv.innerHTML = html;
    }
    function hidePopupMessage()
    {
    var elmDiv = document.getElementById('popupmessage');
    if (elmDiv)
    {
    elmDiv.parentNode.removeChild(elmDiv);
    }
    }
    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;
    }
    </script>


    </head>

    <body onload='init()'>
     
    netnuta, Jul 28, 2008 IP
  2. netnuta

    netnuta Active Member

    Messages:
    123
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    Can any one please help me with this!
    Many thank's in advance
     
    netnuta, Jul 30, 2008 IP