[Javascript] window.open

Peter Brunone peter at brunone.com
Thu Jan 31 14:35:26 CST 2002


Andrew,

    The classic case-sensitivity trap!  This one gets me every time.

Change

remote.location.href = "http://www.mysite.com/"+filename+".cfm";

to

remote.location.href = "http://www.mysite.com/"+fileName+".cfm";
// matches the name of your function parameter


Cheers,

Peter

----- Original Message -----
From: "Andrew Peterson" <webmaster at mail.ioc.state.il.us>
To: <javascript at LaTech.edu>
Sent: Thursday, January 31, 2002 2:12 PM
Subject: [Javascript] window.open


| 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
|
|
|
| >
|
| _______________________________________________
| Javascript mailing list
| Javascript at LaTech.edu
| https://lists.LaTech.edu/mailman/listinfo/javascript
|




More information about the Javascript mailing list