Creating URLs from function call operators

Discussion in 'Javascript' started by Smogo, Jul 8, 2003.

  1. Smogo

    Smogo Guest

    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
     
    Smogo, Jul 8, 2003
    #1
    1. Advertising

  2. "Smogo" <> schreef in bericht
    news:befamu$4gtsm$...
    ....
    > 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
     
    Janwillem Borleffs, Jul 8, 2003
    #2
    1. Advertising

  3. Smogo

    Smogo Guest

    "Janwillem Borleffs" <> wrote in message
    news:3f0b33b2$0$28909$...
    >
    >
    > 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
     
    Smogo, Jul 9, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kaidi
    Replies:
    5
    Views:
    511
    Andrew Thompson
    Jan 4, 2004
  2. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    780
    Sriram Srivatsan
    Aug 12, 2008
  3. Adam Monsen

    JDBC URLs ...not really URLs?

    Adam Monsen, Feb 6, 2009, in forum: Java
    Replies:
    11
    Views:
    6,393
    Adam Monsen
    Feb 8, 2009
  4. Steve T.

    dynamic URLS convert to static URLS for search engines

    Steve T., Mar 1, 2004, in forum: ASP .Net Web Services
    Replies:
    7
    Views:
    325
    Steve T.
    Mar 4, 2004
  5. Creative Acceleration

    Creating Clean URLs

    Creative Acceleration, Aug 1, 2003, in forum: ASP General
    Replies:
    7
    Views:
    148
    Creative Acceleration
    Aug 4, 2003
Loading...

Share This Page