469,280 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,280 developers. It's quick & easy.

Creating URLs from function call operators

Hi, I'm new to JavaScript so forgive me if the answer to this question is
(a) ridiculously obvious, or (b) beyond the realms of JavaScript....

Is it possible to create URLs from function call operators?

For example, I'm trying to program an onClick function which will load a
webpage in one frame and an image in another, based on the name of the
button which is being clicked. So clicking the button with name="help" will
open "webpages/help_page1.html" in one frame, and "images/help.jpg" in
another.

To do this I was hoping that the following would work, where the function
had been called by onClick=activate(help)...

function activate(buttonName) {
webpageURL="webpages/"+buttonName+"_page1.html"
imageURL="images/"+buttonName+".jpg"
parent.frame1.location.href=webpageURL
parent.frame2.picture.src=imageURL
}

But this doesn't work, because the browser (IE6) looks for
"webpages\[object]_page1.html" and "images\[object].jpg".

Hope someone out there can help!

Thanks in advance,

Cliff
Jul 20 '05 #1
2 2017

"Smogo" <sm***@ntlworld.com> schreef in bericht
news:be************@ID-173915.news.dfncis.de...
....
For example, I'm trying to program an onClick function which will load a
webpage in one frame and an image in another, based on the name of the
button which is being clicked. So clicking the button with name="help" will open "webpages/help_page1.html" in one frame, and "images/help.jpg" in
another.

To do this I was hoping that the following would work, where the function
had been called by onClick=activate(help)...

function activate(buttonName) { .... But this doesn't work, because the browser (IE6) looks for
"webpages\[object]_page1.html" and "images\[object].jpg".


Be shure that you pass it a string a not an object, e.g.:

Not:

<input type="button" name="help" onClick="activate(this)">

But

<input type="button" name="help" onClick="activate(this.name)">
JW

Jul 20 '05 #2
"Janwillem Borleffs" <jw*@jwbfoto.demon.nl> wrote in message
news:3f***********************@news.euronet.nl...


Be shure that you pass it a string a not an object, e.g.:

Not:

<input type="button" name="help" onClick="activate(this)">

But

<input type="button" name="help" onClick="activate(this.name)">


Thanks, that fixed it!

Cliff
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Kid A | last post: by
3 posts views Thread by mikea_59 | last post: by
1 post views Thread by George2 | last post: by
21 posts views Thread by coolguyaroundyou | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.