SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Gekco engines and dynamic script src

    I've been struggling with the following:

    In Internet Explorer you can dynamically change the src attribute of a script tag - and the new src will be read and parsed.

    In Gecko browsers - the same is not true:

    var oR = document.getElementById('something');
    alert(oR); // Check we have an object - in case Javascript console misses the error
    oR.src = 'test.js';

    test.js would have a simple alert in it... nothing!

    So I tried the following:

    var scr = document.createElement('SCRIPT');
    scr.language="Javascript";
    scr.type="text/javascript";
    scr.src ="cat.js";
    document.body.appendChild(src);

    Still nothing...
    I tried setting the src after adding the child, nothing.

    Does anyone have any ideas on how to achieve this - short of opening a new page in a new window and document.writing it to that, and letting that refer to it's parent... ( just change top to self.opener) ???

    Any ideas ?


    Cheers

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you can spell it works just fine.

    All those src/scr 's must have got me muddled:

    var scr = document.createElement('SCRIPT');
    scr.language="Javascript";
    scr.type="text/javascript";
    scr.src ="cat.js";
    document.body.appendChild(scr);

    That works fine in Gecko / ie browsers :-)

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •