Forum Moderators: mack
<SCRIPT LANGUAGE="Java Script">
<!--//
function openit(sURL){
newwindow=open(sURL,"newwin","scrollbars=no, toolbar=no,
directories=no, menu bar=no, resizable=yes,
status=yes, width=600, height=500");
}
//-->
</SCRIPT>
and I found a code to pop this window
<a href="popup/t.htm" onclick=openit('http://foo.com/popup/videowindow1.htm');return false;">
or
<a href="openit('http://foo.com/popup/videowindow1.htm')">
both of them does not work. i simply get a 404 error, or open regular browser window.
<a href="popup/t.htm" onclick=openit('http://foo.com/popup/videowindow1.htm');return false;">
or
<a href="openit('http://foo.com/popup/videowindow1.htm')">
I believe you have problems with your code.
In the first example, when the link is clicked, the command tells the browser to:
- Change the current location to "popup/t.htm"
- Open up a new window and display the URL "http://foo.com/popup/videowindow1.htm"
The second is a malformed command - it will simply tell the browser to change the current location to openit('http://foo.com/popup/videowindow1.htm'), which is not what you want.
Instead, try the following:
<a href="#" onClick="openit('http://foo.com/popup/videowindow1.htm')"> HTH,
JP
and when I hover my mouse over the link, i see
[foo.com...]
When I click on it, page reloads and i don't see pop up.
I turned off my popup killer so that's not it. Must be something wrong with my code. I put the script between <head> and </head>
<SCRIPT LANGUAGE="Java Script">
<SCRIPT LANGUAGE="JavaScript"> function openit(sURL){
newwindow=open(sURL,"newwin","scrollbars=no, toolbar=no,
directories=no, menu bar=no, resizable=yes,
status=yes, width=600, height=500");
}
The newwindow command needs to all be one on one line, rather than split across 3.
E.g.
function openit(sURL){
newwindow=open(sURL,"newwin","scrollbars=no, toolbar=no, directories=no, menu bar=no, resizable=yes, status=yes, width=600, height=500");
}
To stop the page jumping to the top everytime you click on the link, you could replace the <a href with the following:
<a href="javascript:openit('http://foo.com/popup/videowindow1.htm')"> HTH,
JP
"...both of them does not work. i simply get a 404 error, or open regular browser window..."
<a href="popup/t.htm" onclick=openit('http://foo.com/popup/videowindow1.htm');return false;">
or
<a href="openit('http://foo.com/popup/videowindow1.htm')">
I believe you have problems with your code.In the first example, when the link is clicked, the command tells the browser to:
- Change the current location to "popup/t.htm"
- Open up a new window and display the URL "http://foo.com/popup/videowindow1.htm"The second is a malformed command - it will simply tell the browser to change the current location to openit('http://foo.com/popup/videowindow1.htm'), which is not what you want..."
The first example say 'when a mouse click occurs then run the openit() function'. The 'return false;' bit tells the browser: 'After the function completes you can stop, and ignore the "href=..."'. If javascript is not enabled on the browser, then the href=... stuff is used instead.
The second example is a shorthand for <a href="javascript:openit('...');">. I don't think it is malformed, although (with or without the "javascript:") it is not as good practice, and the first one is better, because the second one won't work if the visitor doesn't have javascript enabled.
Shawn