javascript bg image

Discussion in 'Javascript' started by warth33@hotmail.com, Feb 28, 2008.

  1. Guest

    Hello

    I have to change a div's background image on the fly. The problem is
    that the url is built on the fly too.

    var url = link.replace("a", "b");

    Thus the location of the image is contained in the variable url. How
    do I pass this to the function?

    document.getElementById('img_div').style.backgroundImage = "url( '" +
    url + "') ";

    This of course didnt work. I have tried a lot of alternatives, putting
    \ almost everywhere. But none worked. is there a solution to this?
    , Feb 28, 2008
    #1
    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. Jerry J
    Replies:
    0
    Views:
    530
    Jerry J
    Jul 18, 2003
  2. Mike John
    Replies:
    0
    Views:
    486
    Mike John
    Jul 28, 2003
  3. Gary B

    Image can't hold an image?

    Gary B, Jul 31, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    323
    Steve C. Orr, MCSD
    Aug 1, 2003
  4. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,237
    Kartic
    Jan 26, 2005
  5. Ryan Sullivan

    Javascript Image Viewer from Image Map

    Ryan Sullivan, Feb 29, 2004, in forum: Javascript
    Replies:
    3
    Views:
    227
Loading...

Share This Page