it was a few years since I used javascript, but for a study i need to use a javascript function, which opens a new window to launch questions for the users, who leave the homepage. So I tried again with some coding...
When this function is called on unload, the alert (to test the function) pops up, but the window doesn't - both with IE and FF (although in IE it works locally on my computer ):
FF tells me "winout is null winout.focus();"
Here's the code from js-File:
var winout = null;
var exit=0;
var w = 300;
var h = 200;
var qpage_user = "http://www.xyQuestions1.de";
var qpage_no_user = "http://www.yzQuestions2.de";
var pagename = "Befragung";
var q_settings = 'height=' + h + ',';
q_settings += 'width=' + w + ',';
function nouser (exit) {
pagename = "Befragung_no_User";
if (exit == 1 && user != "yes") // user is defined later
{
if(winout == null)
{
window.alert(user);
winout = window.open(qpage_no_user,pagename,q_settings);
winout.focus();
If the user has pop ups blocked, the window.open function can return a null value. Browsers generally only open windows as a result of a user generated event, such as a click. If you try opening a new window using window.open on page load, and the user is blocking pop ups, the window.open function returns a null value. You'll need to guard against this.
Bookmarks