SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    INCLUDE <script> IN document.write method

    Greetings...

    How can a fellow include an external javascript file inside a document.write method?

    I have used the following:

    <head>
    <script type="text/javascript">
    function fName() {
    document.write('<script language="text/javascript" src="./file.js"><\/script>');
    }
    </script>
    </head>
    <body onload="fName();">

    </body>

    The onload event is triggered when the page has loaded...Document.write tries to write to the document that executes the write method....

    If i have said something wrong, do correct me please....

    So far so good...When the page executes the document.write CLEARS the content of the page and writes new content...!!!!!!

    Do i need to place the script inside the body element to prevent the above from happening???


    Thanx in advance!!!!!

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What are you trying to do...and why? If you want to include the file, why not just include it in your header section?

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2002
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ooops...you've got a point there...

    i have a flash sniffer and i want to load different menus (one that supports flash and another plain mouseover javascripts) depending on the existence or not of the plugin...


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
  •