Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript Error: illegal URL method.....

Status
Not open for further replies.

hablablow

Programmer
Sep 9, 2000
115
FR

Hi,
i am trying to open a second popup from a parent popup when the user leaves it.
Works in IE but not in Netscape. The Js console returns this message:

JavaScript Error: illegal URL method 'news.htm'

Here is my code:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

<!--
var exwin=null;
function News(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
if(window.screen)if(isCenter)if(isCenter==&quot;true&quot;){
var myLeft = (screen.width-myWidth)/2+255;
var myTop = (screen.height-myHeight)/2;
features+=(features!='')?',':'';
features+=',left='+myLeft+',top='+myTop;
}
if(exwin!=null)exwin.close();
window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}


//-->

</SCRIPT>
</HEAD>
<BODY LEFTMARGIN=&quot;0&quot; TOPMARGIN=&quot;0&quot; MARGINWIDTH=&quot;0&quot; MARGINHEIGHT=&quot;0&quot;
ONLOAD=&quot;setTimeout('window.close()',40000)&quot;
ONUNLOAD=&quot;javascript:News('news.htm','news','','207','300','true')&quot;>

(...)

If you do the news function in onload it works just fine.
But doesn't work in onunload ?
Any help is welcomed !
Thanks for your incomming messages.
Hablablow.
 
Try this instead:

Add this function:
Code:
function workaround()
{
window.close();
News(&quot;news.htm&quot;,&quot;news&quot;,&quot;&quot;,&quot;207&quot;,&quot;300&quot;,&quot;true&quot;);
}

Then the body tag:
Code:
<BODY LEFTMARGIN=&quot;0&quot; TOPMARGIN=&quot;0&quot; MARGINWIDTH=&quot;0&quot; MARGINHEIGHT=&quot;0&quot; ONLOAD=&quot;setTimeout('workaround()',1000)&quot;>
*Note, I changed the time for checking reasons, you'll want to change it back &quot;The surest sign that intelligent life exists elsewhere in the universe is that it has never tried to contact us&quot;
Bill Watterson, Calvin & Hobbes
 
Thanks Bentley22 for your answer but this doesn't work either.

I will try to be more precise.
I load a page index.htm : this page launches, with onload, a popup A.
Now the code above is in this popup A.
2 possibiblities:
- When the windows closes itself after the delay it opens directly another popup B
- If the user closes the window the classic way before the end of delay then the popup B appears also

That is why i use the onunload function that tells the browser: when the popup A is closed then immediatly open the popup B ---- at a given position ---- ( see details of my function &quot;news&quot; )
In all cases this works in Ie but netscape Js console will always return:
JavaScript Error: illegal URL method 'news.htm'

I tryed some searches on the net about this message and i found a partial answer :
&quot; NN4 treats a stand alone file name with window.open method as a local file specification. What a quirk. So using a whole URL string would work fine. &quot;

I don't understand it. So maybie this is a little clearer ?
Not for me...

Any help is welcomed !
Thanks for your incomming messages.
Hablablow.

 
Have you tried using the full url to the file? &quot;The surest sign that intelligent life exists elsewhere in the universe is that it has never tried to contact us&quot;
Bill Watterson, Calvin & Hobbes
 
Sorry but what should be the full url as all the htm docs are in the same folder ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top