how to open a new window using script src

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r0nald04
    New Member
    • Aug 2012
    • 1

    how to open a new window using script src

    <script>
    var adfly_id = 165909;
    var adfly_advert = 'int';
    var frequency_cap = 5;
    var frequency_delay = 5;
    var init_delay = 3;
    ImageWindow=win dow.open("", "newwin");
    </script>
    <script src="http://adf.ly/js/entry.js"></script>

    how can i open that on new window??
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    #2
    Use this script to create a new window and then populate the new window with your variables. Do remember that both the main and sub-window have to be served up by the same domain. Otherwise this is a security risk and is not premitted.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>Main Window</title>
    <script type="text/javascript">
    // global variable for subwindow reference
    var newWindow;
    // generate and fill the new window
    function makeNewWindow() {
        // make sure it isn't already opened
        if (!newWindow || newWindow.closed) {
            newWindow = window.open("","sub","status,height=200,width=300");
            // delay writing until window exists in IE/Windows
            setTimeout("writeToWindow()", 50);
        } else if (newWindow.focus) {
            // window is already open and focusable, so bring it to the front
            newWindow.focus();
        }
    }
    function writeToWindow() {
        // assemble content for new window
        var newContent = "<html><head><title>Secondary  Window</title></head>";
        newContent += "<body><h1>This is a script-created window.</h1>";
        newContent += "</body></html>";
        // write HTML to new window document
        newWindow.document.write(newContent);
        newWindow.document.close(); // close layout stream
    }
    </script>
    </head>
    <body>
    <h1>Communicating with a New Window</h1>
    <hr /> 
    <form>
    <input type="button" value="Create New Window" onclick="makeNewWindow();" />
    </form>
    </body>
    </html>

    Comment

    Working...