Stewie Griffin Stewie Griffin - 3 months ago 13
Javascript Question

Set title in the window popup

Is it possible to set a title in the window popup?

I have this in javascript:

var popup = window.open('......');
popup.document.title = "my title";


but this does not work..still can't see any title

EDIT: the page popup is displaying is .aspx and it HAS a title tag, but still can't see that on the popup window..

Answer

Since popup.onload does not seem to work, here is a workaround: http://jsfiddle.net/WJdbk/.

var win = window.open('', 'foo', ''); // open popup

function check() {
    if(win.document) { // if loaded
        win.document.title = "test"; // set title
    } else { // if not loaded yet
        setTimeout(check, 10); // check in another 10ms
    }
}

check(); // start checking
Comments