[Javascript] window.open

Esther_Strom at hmco.com Esther_Strom at hmco.com
Thu Jan 31 14:40:01 CST 2002


Andrew,

In your case, AddrInd isn't a variable - it's the actual file name you're
passing. So you need to put single quotes around it in the link tag:

<A HREF="javascript: makeRemote('AddrInd')">click here</a>

This way, javascript knows to take the literal text inside the quotes and
parse it into the link, instead of looking for a variable called AddrInd.

Hope this helps,

Esther



                                                                                                                                            
                      "Andrew Peterson"                                                                                                     
                      <webmaster at mail.ioc.s         To:      <javascript at latech.edu>                                                        
                      tate.il.us>                   cc:                                                                                     
                      Sent by:                      Subject: RE: [Javascript] window.open                                                   
                      javascript-admin at LaTe                                                                                                 
                      ch.edu                                                                                                                
                                                                                                                                            
                                                                                                                                            
                      01/31/02 02:32 PM                                                                                                     
                      Please respond to                                                                                                     
                      javascript                                                                                                            
                                                                                                                                            
                                                                                                                                            




DOH!

Thanks Peter - that was certainly part of the problem. However, I think
there's more. Whatever variable I pass in, I get the error message that
that
variable is undefined. This is probably a dumb question, but do I have to
set up an expression to create the variable? In the example below:

> | <A HREF="javascript: makeRemote(AddrInd)">click here</a>

I get the message that AddrInd is undefined.

My js code again:

> | <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>
> |

Thanks Again,
Andrew

> -----Original Message-----
> From: javascript-admin at LaTech.edu
> [mailto:javascript-admin at LaTech.edu]On
> Behalf Of Peter Brunone
> Sent: Thursday, January 31, 2002 2:35 PM
> To: javascript at LaTech.edu
> Subject: Re: [Javascript] window.open
>
>
> 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
> |
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript







More information about the Javascript mailing list