www.webdeveloper.com
Results 1 to 4 of 4

Thread: Turn variable into <script type="text/javascript" src="lalala.js"></script>

  1. #1
    Join Date
    Feb 2011
    Location
    Sapporo, Hokkaido, Japan
    Posts
    180

    Smile Turn variable into <script type="text/javascript" src="lalala.js"></script>

    I have a variable that says
    Code:
    var Fname = lalala.js;
    How do I write a function that moves the variable into a line of code like this?

    Code:
    <script type="text/javascript" src="lalala.js"></script>
    The problem I having is the quotation marks as far as I know.

    Glen R
    http://a4jp.com/index-en.html

  2. #2
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Code:
    document.write("<script type=\"text/javascript\" src=\"" + Fname + "\"></script>");
    Note the escaped quotes. (\") Important.

    ^_^

  3. #3
    Join Date
    Feb 2011
    Location
    Sapporo, Hokkaido, Japan
    Posts
    180
    How do I make it so it doesn't delete everything else on a webpage or where should I put the code? Just in the head of the HTML in something?

    Glen R
    http://a4jp.com/index-en.html

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    My suggestion will not delete anything. If you are experiencing something like that, I can assure you that it isn't
    Code:
    <script type="text/javascript">
    var Fname = "lalala.js";
    document.write("<script type=\"text/javascript\" src=\"" + Fname + "\"></script>");
    </script>
    And, yes, it should be placed within the HEAD tags.

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles