Results 1 to 3 of 3

Thread: Using Javascript variable in src tag?

  1. #1
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Using Javascript variable in src tag?

    Hello all..
    I am trying to use a Javascript variable in the src tag of a iframe thus loading the correct page in the iframe based on the variable.

    I have so far been able to do a document.write(argument) and I can see the correct variable written out....I just need to get it into that src!!

    Thanks in advance!

  2. #2
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Nevermind....figured it out.

    Not sure if it was the best way...but I just did a document.write of the line of html code with the variable in there.

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's one way. A better one is to have the src originally set to a suitable default variable for non-JS browsers, then change it with a <script> later on in the document (or using onload).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •