Creating URLs from function call operators

S

Smogo

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
 
J

Janwillem Borleffs

"Smogo" <[email protected]> schreef in bericht
....
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
 
S

Smogo

Janwillem Borleffs said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top