[Javascript] window.open
Andrew Peterson
webmaster at mail.ioc.state.il.us
Thu Jan 31 14:12:16 CST 2002
Hi,
I'm learning JS in depth but in the meantime I need help modifying this
generic window.open script that merely opens up a webpage in another window.
Instead of having the webpage hard coded, I'd like to pass it in.
Currently, the hard coded script is setup like so. I create a hyperlink:
<A HREF="javascript: makeRemote()">click here</a>
Which calls the function:
<script>
function makeRemote() {
remote =
window.open("","remotewin","width=300,height=110,scrollbars=1");
remote.location.href = "http://www.mysite.com/AddrInd.cfm";
if (remote.opener == null) remote.opener = window;
remote.opener.name = "opener";
}
//-->
</script>
What I'd like to do is pass in the file name, in this case AddrInd.cfm. I
was trying something like:
<A HREF="javascript: makeRemote(AddrInd)">click here</a>
and the script would look like:
<script>
function makeRemote(fileName) {
remote =
window.open("","remotewin","width=300,height=110,scrollbars=1");
remote.location.href = "http://www.mysite.com/"+filename+".cfm";
if (remote.opener == null) remote.opener = window;
remote.opener.name = "opener";
}
//-->
</script>
But I get an undefined error. I also am fairly certain I've passed in the
variable wrong and have the quotes all screwed up.
Any help with this is greatly appreciated.
Thanks!
Andrew
>
More information about the Javascript
mailing list