July 17, 200719 yr I am trying to use some java script which is brave for me because Im rubbish at it. I have been trying to work this problem out on my own for ages because it seems like it should be so simple....but now after hours of banging my head against a brick wall Im begging anyone who knows for help..... Im trying to open a new window on a time delay...which i can do and Im also trying to specify that window's size and url etc which I can do. BUT although I can do these two things seperately...but when I combine them I manage to mess it up (probably because I dont fully understand how to structure. the code I have to make my window open at right spec etc is to go inside the body tag apparently like <body onload="java script:window.open('1.html','PAGE NAME','height=615,width=6684,scrollbars=yes')"> the code i have found to open window with set delay (in this eg 10 seconds i believe) is setTimeout('window.open()',10000) thus my (constantly failing) combination of the two is like this <body onload="java script:set Timeout('window.open('1.html','PAGE NAME','height=615,width=6684,scrollbars=yes')',10000)"> <p> blah blah where normal content goes </p> </body> Can anyone help? Im sure its achingly simple to open a window of a set size with a time delay...and it's making me really frustrated not being able to figure it out. Any help will be massively appreciated.
August 9, 200719 yr the problem you have here is nested quotation marks. to get past this, use \" rather than ' in the window.open. your code should look like this now, and it should work: <body onload="java script:set Timeout('window.open(\"1.html\",\"PAGE NAME\",\"height=615,width=6684,scrollbars=yes\")',10000)"> <p> blah blah where normal content goes </p> </body> Of course, you could write a custom function to make this a lot easier, if it is to be reused: function openWindow( url, name, width, height, scroll, timeout ) { var newwindow = window.open( url, name, 'width='+width+',height='+height,scrollbars=yes'); setTimeout( newwindow, timeout); } and your body would look like this now: <body onload="openWindow( '1.html', 'Page Name', 6684, 615, 10000 );"> hope this helps.
Create an account or sign in to comment