Creating URLs from function call operators

Giganews Newsgroups
Subject: Creating URLs from function call operators
Posted by:  Smogo (smo…@ntlworld.com)
Date: Tue, 8 Jul 2003

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

Replies