createTextNode and IE7

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randy Webb

    #16
    Re: createTextNode and IE7

    Peter Michaux said the following on 12/1/2006 11:27 AM:
    Hi Randy,
    >
    Randy Webb wrote:
    >When running this code in IE7:
    >>
    >function insertScript() {
    > var newScript = document.create Element('script ');
    > newScript.type = "text/javascript";
    > var s = document.create TextNode("alert ('hi');");
    > newScript.appen dChild(s); // problem line
    > document.getEle mentById("myDiv ").appendChild( newScript);
    >}
    >>
    >window.onload= insertScript;
    >>
    >I get this error:
    >>
    >Unexpected call to method or property access
    >>
    >And a pointer that points to the newScript.appen dChild(s) line.
    >>
    >Am I using createTextNode incorrectly or is IE7 getting it wrong?
    >>
    >The function, as written, works correctly in FF2.0, Opera9 and AIUI,
    >
    What is "AIUI"?
    No, it doesn't support window.opera but it has all the rest of your
    nightmares :)
    >Safari1.3.2 Its an attempt to get around Safari not supporting the
    >setting of the .text property of a script element. If IE7 simply won't
    >create the text and append it then feature testing for createTextNode
    >won't work. So, I came up with the idea of attempting to set the .text
    >property with a variable definition then reading that variable.
    >
    I was doing this weeks ago :) You even saw a page of mine that did
    exactly this. Remember that "insert code" thing I had for code
    examples.
    Yes, this thread:

    <URL:
    http://groups-beta.google.com/group/comp.lang.javas cript/browse_thread/thread/499fb07a38e7107 7/3b313bfc2c0090e 6?lnk=gst&q=cre ateTextNode+saf ari&rnum=3#3b31 3bfc2c0090e6>

    Was the one I remembered seeing that had the code I used in it and where
    I got the idea from that caused this thread to be created.

    Below is the code I used to determine if the page is capable
    of inserting scripts with your technique plus the necessary option for
    Safari. I try the IE method first because as far as i remember it
    doesn't error in Safari but trying them in the other order does error
    in IE. However I did put the tests in try-catch blocks for good (or
    bad) measure.
    >
    function newInserter() {
    >
    var hooks = [
    function(script , code) { // IE
    script.text = code;
    },
    function(script , code) { // Safari
    code = document.create TextNode(code);
    script.appendCh ild(code);
    }
    ];
    >
    var hook = null;
    function insertExampleCo de(code) {
    var script = document.create Element('script ');
    script.type = 'text/javascript';
    hook(script, code);
    document.body.a ppendChild(scri pt);
    }
    >
    var testCode = "var testInsertion={ b:3};"
    for (var i=0; i<hooks.length ; i++) {
    hook = hooks[i];
    try {
    insertExampleCo de(testCode);
    if (testInsertion && testInsertion.b === 3) {
    return insertExampleCo de;
    }
    } catch (e) {}
    }
    return null;
    }

    Looks like a convoluted way of doing this:

    function insertScript(sc riptContents) {
    var useIt = false;
    var testScript = document.create Element('script ');
    testScript.type = "text/javascript";
    testScript.text = "var useText=true";
    document.getEle mentById("myDiv ").appendChild( testScript);

    var newScript = document.create Element('script ');
    newScript.type = "text/javascript";
    if(useText)
    {
    newScript.text = scriptContents;
    }
    else
    {
    //Opera 9 falls through to this branch.
    var s = document.create TextNode(script Contents);
    newScript.appen dChild(s);
    }
    document.getEle mentById("myDiv ").appendChild( newScript);
    }

    Although the only browser I know of that won't use createTextNode is IE.

    What does that code do in Safari (in fact, any mac browser) when called
    with a insertScript('a lert("It worked")') ?
    >If it is
    >set, then use the .text property. If it isn't set, then use
    >createTextNode .
    >
    Just because text property doesn't work, it doesn't mean that
    createTextNode will work. It is just as easy to test both as test one.
    It's possible, but unless I see one, or hear of one, I will leave it as
    simple as possible which is the goal.
    >Not sure how reliable it is so I thought about using an
    >IE conditional to isolate IE and go based on that but it reeks of
    >browser detection.
    >
    I just retested the above coded with success in Mac/Safari 2, Mac/Opera
    9, Mac/Firefox 1.5, Win/IE 5.5, Win/IE 6, Win/Netscape 6.
    What do the Mac browsers (and even NS6 Win) do with the code above I posted?
    Clearly there is appeal to your technique which is why I played with it
    until I found the Safari problem. Then I started to get nervous that
    some other browser might be able to do XHR but the script blocks
    wouldn't run.
    I don't use XHR so this is mostly an academic exercise for me as I use
    ..js files and dynamically load them on the fly.
    The advantage of using eval() is that as long as the programmer knows
    how the code has to be written then it is extremely likely that the
    browser will be able to run the scripts.
    Most JS programmers don't understand how to control eval and when to/not
    to use it though. The major drawback to eval here is the scope chain. I
    haven't decided on an attempted course to try to deal with the scope
    issue yet but I have some ideas.
    Success is the most important part.
    Without a doubt.
    If the script blocks are written with care then they could also
    run if your technique is proven to work and the use of eval is changed
    to your technique.
    I don't know that I can make mine work but I won't stop trying to :) I
    have been modifying the loadJSFile function for about 5 years now :)

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javas cript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • Peter Michaux

      #17
      Re: createTextNode and IE7

      Hi Randy,

      Randy Webb wrote:
      >
      Below is the code I used to determine if the page is capable
      of inserting scripts with your technique plus the necessary option for
      Safari. I try the IE method first because as far as i remember it
      doesn't error in Safari but trying them in the other order does error
      in IE. However I did put the tests in try-catch blocks for good (or
      bad) measure.

      function newInserter() {

      var hooks = [
      function(script , code) { // IE
      script.text = code;
      },
      function(script , code) { // Safari
      code = document.create TextNode(code);
      script.appendCh ild(code);
      }
      ];

      var hook = null;
      function insertExampleCo de(code) {
      var script = document.create Element('script ');
      script.type = 'text/javascript';
      hook(script, code);
      document.body.a ppendChild(scri pt);
      }

      var testCode = "var testInsertion={ b:3};"
      for (var i=0; i<hooks.length ; i++) {
      hook = hooks[i];
      try {
      insertExampleCo de(testCode);
      if (testInsertion && testInsertion.b === 3) {
      return insertExampleCo de;
      }
      } catch (e) {}
      }
      return null;
      }
      >
      >
      Looks like a convoluted way of doing this:
      >
      function insertScript(sc riptContents) {
      var useIt = false;
      var testScript = document.create Element('script ');
      testScript.type = "text/javascript";
      testScript.text = "var useText=true";
      document.getEle mentById("myDiv ").appendChild( testScript);
      >
      var newScript = document.create Element('script ');
      newScript.type = "text/javascript";
      if(useText)
      {
      newScript.text = scriptContents;
      }
      else
      {
      //Opera 9 falls through to this branch.
      var s = document.create TextNode(script Contents);
      newScript.appen dChild(s);
      }
      document.getEle mentById("myDiv ").appendChild( newScript);
      }
      Each time you insert a script you are making the same test. If the page
      will only insert once then that is fine. However with multiple uses you
      are making the same test unnecessarily. Of course you already know this
      and it is personal preference. I like Richard's style of testing once
      and then setting a very short efficient function to be used repeatedly.

      Although the only browser I know of that won't use createTextNode is IE.
      >
      What does that code do in Safari (in fact, any mac browser) when called
      with a insertScript('a lert("It worked")') ?
      <snip>
      What do the Mac browsers (and even NS6 Win) do with the code above I posted?
      If you post some examples at a few different URLs then I can click them
      in Safari 2.0.4 and if the issue is still interesting in a few weeks I
      can also click them in Safari 1.3.9.

      The advantage of using eval() is that as long as the programmer knows
      how the code has to be written then it is extremely likely that the
      browser will be able to run the scripts.
      >
      Most JS programmers don't understand how to control eval and when to/not
      to use it though.
      Unless the alternative is better and has less drawbacks, I really am ok
      with letting other programmers shoot themselves in the foot as long as
      the capability to do it right is in the compromise solution.

      I don't know that I can make mine work but I won't stop trying to :) I
      have been modifying the loadJSFile function for about 5 years now :)
      Using eval with care will work today (and I'm all stressed about
      setting opacity well). Not that your attempts should be discouraged.
      I'd rather do it your way.

      Peter

      Comment

      • Julian Turner

        #18
        Re: createTextNode and IE7


        Randy Webb wrote:

        [snip]
        And, the IFrame tricks discussed are about getting eval'ed code out of
        the current scope into a scope of it's own and I am trying to get code
        back into it's proper scope.
        [/snip]

        Hi

        I appreciate the point your are making here, and that the IFrame trick
        is not relevant.

        I am not sure I fully understand the issues you have with eval and
        proper scope, and therefore why inserting script with a script tag is
        preferrable to eval'ing it.

        I think I understand that if I eval script, then it will get its own
        scope based on the scope of the function in which it it is eval'd.

        Is the problem this: your script is trying to introduce variables and
        declared functions to be available in the scope chains of
        **previously** imported script? Or am I way off the mark?

        Regards

        Julian Turner

        Comment

        • Randy Webb

          #19
          Re: createTextNode and IE7

          Julian Turner said the following on 12/4/2006 7:40 AM:
          Randy Webb wrote:
          >
          [snip]
          >And, the IFrame tricks discussed are about getting eval'ed code out of
          >the current scope into a scope of it's own and I am trying to get code
          >back into it's proper scope.
          [/snip]
          >
          Hi
          >
          I appreciate the point your are making here, and that the IFrame trick
          is not relevant.
          It may end up not being irrelevant, I honestly don't know yet. I do
          think it doesn't solve the issue I am pondering on though :) And, to be
          totally honest, I don't have the issue in any site I am working on. It's
          more of a mental exercise than anything else.
          I am not sure I fully understand the issues you have with eval and
          proper scope, and therefore why inserting script with a script tag is
          preferrable to eval'ing it.
          Simple scenario. Let's say a page is loaded via XHR. That document has a
          script block in it with this code snippet:

          <script>
          var myVar = "My name is Randy";
          </script>

          Just any global variable.

          You load the HTML, insert it in a container, then want to execute the
          script block. You run a function that evals the script contents. myVar
          then becomes local to the function.

          The biggest thing? I hate eval :)

          Second scenario is one that I can not come up with a reasonable reason
          to ever do but it involves a script block that traverses the tree going
          upwards using parentNode to get to an element. As I say, that is a
          perverse scenario that if I ever saw actual code that did it I would
          probably wonder what insane asylum the author was a patient at.
          I think I understand that if I eval script, then it will get its own
          scope based on the scope of the function in which it it is eval'd.
          Yes it does.

          function function1(theAr g){
          eval(theArg)
          }
          function function2(){
          alert(myVar)
          }

          function1('var myVar = "My name is Randy"')

          If the argument to that function1 call is the string being loaded via
          XHR and passed to function1 to be executed, then in it's original form
          it would be a global variable. After being eval'ed it becomes local.
          Using createTextNode or the .text property it retains it's global scope.
          Is the problem this: your script is trying to introduce variables and
          declared functions to be available in the scope chains of
          **previously** imported script? Or am I way off the mark?
          Close. Three years ago you didn't see questions in this group with
          regards to XMLHttpRequest and/or AJAX very often. Now, you see a
          kazillion of them. The next phase of that, to me, is going to be script
          issues and it is already happening where people are asking "How do I
          make my scripts execute when loaded with AJAX" and I am simply trying to
          be ahead of it and come up with an answer before the onslaught happens.

          Personally, I don't use AJAX to load data. What dictates how you load
          data is how your back end is set up. People seem to think that you can
          simply take a huge site and convert it to AJAX and everything keeps
          going when that isn't true. If you have a site that has, say, 100 pages
          to it. OK, lets make it an AJAX site. Create a new first page, use AJAX
          to load the other pages and drop them in a div container. Simple, and
          you now have an "AJAX site". That is what it seems a lot of people are
          doing and it runs into the "My scripts don't execute" scenario. Where if
          the site is setup and maintained to be an AJAX driven site then the
          "pages" aren't complete HTML pages and don't stand on there own.

          The approach I use, and prefer, for loading data is .js files and
          loading them on the fly. The back end still has to be set up to create
          those .js files and the main page is set up to handle it. I just find
          the .js files simpler and more reliable than AJAX is all.

          --
          Randy
          Chance Favors The Prepared Mind
          comp.lang.javas cript FAQ - http://jibbering.com/faq
          Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

          Comment

          • Peter Michaux

            #20
            Re: createTextNode and IE7

            Randy Webb wrote:
            Simple scenario. Let's say a page is loaded via XHR.
            Maybe this is just semantics but folks don't usually load a page with
            XHR but rather an HTML snip that may contain script blocks.

            The biggest thing? I hate eval :)
            but Randy, eval is the only way to write dynamic code like this...

            eval("myObj." + foo + "=" + bar);

            :-) Ok. Seriously...

            I haven't run tests, but as far as I know, eval is the quickest way to
            parse trusted json. The alternative is a relatively lengthy json parser
            written in JavaScript.

            Three years ago you didn't see questions in this group with
            regards to XMLHttpRequest and/or AJAX very often. Now, you see a
            kazillion of them. The next phase of that, to me, is going to be script
            issues and it is already happening where people are asking "How do I
            make my scripts execute when loaded with AJAX" and I am simply trying to
            be ahead of it and come up with an answer before the onslaught happens.
            This attitude plus FAQ mantainer: a true humanitarian!
            Personally, I don't use AJAX to load data. What dictates how you load
            data is how your back end is set up. People seem to think that you can
            simply take a huge site and convert it to AJAX and everything keeps
            going when that isn't true. If you have a site that has, say, 100 pages
            to it. OK, lets make it an AJAX site. Create a new first page, use AJAX
            to load the other pages and drop them in a div container. Simple, and
            you now have an "AJAX site". That is what it seems a lot of people are
            doing and it runs into the "My scripts don't execute" scenario. Where if
            the site is setup and maintained to be an AJAX driven site then the
            "pages" aren't complete HTML pages and don't stand on there own.
            >
            The approach I use, and prefer, for loading data is .js files and
            loading them on the fly. The back end still has to be set up to create
            those .js files and the main page is set up to handle it. I just find
            the .js files simpler and more reliable than AJAX is all.
            But once a site starts submitting forms with Ajax then the whole site
            may as well switch over to Ajax all together, don't you think?

            Peter

            Comment

            • Julian Turner

              #21
              Re: createTextNode and IE7


              Randy Webb wrote:

              [snip]
              You load the HTML, insert it in a container, then want to execute the
              script block. You run a function that evals the script contents. myVar
              then becomes local to the function.
              [/snip]

              I see the point.

              I suppose the question then is in what circumstances is myVar being
              local a problem that does not have a work-around?
              The biggest thing? I hate eval :)
              It's reputation is definitely not helped when it is misused.

              For a particularly egregious example of misuse, and for fun only, I use
              eval for my own libraries to nest my modules (with a downward only
              dependency)

              E.g.

              module1 - core functions
              module2 - Array, String - uses module1
              module3 - HTML - uses modules 2 and 2

              function module1()
              {
              this.closure = function(source )
              {
              var retVal;
              eval(source);
              return retVal;
              };

              function module1Function () {
              alert("hello from module1");
              }
              this.module1Fun ction = module1Function ;
              }

              function module2()
              {
              this.closure = function(source )
              {
              var retVal;
              eval(source);
              return retVal;
              };

              function module2Function () {
              module1Function (); // Will be in scope chain
              }
              this.module2Fun ction = module2Function ;
              }

              function module3()
              {
              function module3Function () {
              module2Function (); // Will be in scope chain
              }
              this.module3Fun ction = module3Function
              }

              module1 = new module1();
              module2 = module1.closure (module2.toStri ng() + " retVal = new
              module2()");
              module3 = module2.closure (module3.toStri ng() + "retVal = new
              module3()");

              module3.module3 Function();

              The real version is a little more friendly, but that hopefully
              illustrates the insane gist of it.

              I know, I know, closures, scopes and scope chain look-ups lead to poor
              memory and speed performance, but in practice I am not noticing much of
              a performance hit for modest applications.
              Second scenario is one that I can not come up with a reasonable reason
              to ever do but it involves a script block that traverses the tree going
              upwards using parentNode to get to an element. As I say, that is a
              perverse scenario that if I ever saw actual code that did it I would
              probably wonder what insane asylum the author was a patient at.
              I am not sure I follow this.

              [snip]
              Close. Three years ago you didn't see questions in this group with
              regards to XMLHttpRequest and/or AJAX very often. Now, you see a
              kazillion of them. The next phase of that, to me, is going to be script
              issues and it is already happening where people are asking "How do I
              make my scripts execute when loaded with AJAX" and I am simply trying to
              be ahead of it and come up with an answer before the onslaught happens.
              [/snip]

              Anticipation is good.

              [snip]
              The approach I use, and prefer, for loading data is .js files and
              loading them on the fly. The back end still has to be set up to create
              those .js files and the main page is set up to handle it. I just find
              the .js files simpler and more reliable than AJAX is all.
              [/snip]

              It is also patented!

              <URL:http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PT O1&Sect2=HITOFF &d=PALL&p=1&u=% 2Fnetahtml%2FPT O%2Fsrchnum.htm &r=1&f=G&l=50&s 1=6,941,562.PN. &OS=PN/6,941,562&RS=PN/6,941,562>

              Regards

              Julian

              Comment

              • Randy Webb

                #22
                Re: createTextNode and IE7

                Julian Turner said the following on 12/5/2006 7:45 AM:
                Randy Webb wrote:
                <snip>
                >The approach I use, and prefer, for loading data is .js files and
                >loading them on the fly. The back end still has to be set up to create
                >those .js files and the main page is set up to handle it. I just find
                >the .js files simpler and more reliable than AJAX is all.
                [/snip]
                >
                It is also patented!
                >
                <URL:http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PT O1&Sect2=HITOFF &d=PALL&p=1&u=% 2Fnetahtml%2FPT O%2Fsrchnum.htm &r=1&f=G&l=50&s 1=6,941,562.PN. &OS=PN/6,941,562&RS=PN/6,941,562>
                How does one challenge a US Patent then? I beat them to that by about 4
                years or so. And, I can prove it.

                March 9, 2003 is the date on the files in this FTP listing:

                <URL: ftp://members.aol.com/justhikk/>

                And that is precisely why I haven't updated that page is to date when I
                first started using dynamic loading script files. And that is not when I
                first started using it, it is when that page got last updated (after I
                had it working). The only problem with that page is about half the .js
                files didn't get created/uploaded.

                So, how do I get my patent they stole from me?

                --
                Randy
                Chance Favors The Prepared Mind
                comp.lang.javas cript FAQ - http://jibbering.com/faq
                Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

                Comment

                • Julian Turner

                  #23
                  Re: createTextNode and IE7


                  Randy Webb wrote:
                  How does one challenge a US Patent then? I beat them to that by about 4
                  years or so. And, I can prove it.
                  >
                  March 9, 2003 is the date on the files in this FTP listing:
                  >
                  <URL: ftp://members.aol.com/justhikk/>
                  >
                  And that is precisely why I haven't updated that page is to date when I
                  first started using dynamic loading script files. And that is not when I
                  first started using it, it is when that page got last updated (after I
                  had it working). The only problem with that page is about half the .js
                  files didn't get created/uploaded.
                  >
                  So, how do I get my patent they stole from me?
                  I just mentioned it for a laugh :)

                  I don't know much about the US patent system, but I get the strong
                  impression (and I am happy to be corrected) that the US patent office
                  does not really do much of a prior-art search, and accepts almost
                  anything it is given, so that a number of speculative applications make
                  it onto the books and then get challenged later (if you have the money)
                  or ignored. If I am right, I can't say I agree with that system,
                  particularly when it comes to software, as patents and software do not
                  sit easily together.

                  The open source movement is partly in existence as a counter-balance to
                  this problem, I think.

                  Certainly in the UK (my jurisdiction), the patent office takes a lot
                  more persuading to grant a patent, software is very hard to patent
                  (although Microsoft and other large concerns are always trying to lobby
                  for more), and a patent can always be challenged by "prior art" or
                  "obviousnes s" later on.

                  Regards

                  Julian

                  Comment

                  • VK

                    #24
                    Re: createTextNode and IE7

                    <URL:http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PT O1&Sect2=HITOFF &d=PALL&p=1&u=% 2Fnetahtml%2FPT O%2Fsrchnum.htm &r=1&f=G&l=50&s 1=6,941,562.PN. &OS=PN/6,941,562&RS=PN/6,941,562>
                    >
                    How does one challenge a US Patent then? I beat them to that by about 4
                    years or so. And, I can prove it.
                    >
                    March 9, 2003 is the date on the files in this FTP listing:
                    >
                    <URL: ftp://members.aol.com/justhikk/>
                    Alas, 2003 is not old enough, so you may safely remove these files.

                    Their priority is protected by the U.S. Provisional Application No.
                    60/251,056 filed Dec. 1, 2000

                    This way you need a something older than 12.01.2000

                    I also noticed an important patent status change since the last time I
                    checked it: it is not "pending request" anymore, it's "patented case"
                    now:

                    <http://portal.uspto.go v/external/portal/!ut/p/_s.7_0_A/7_0_CH/.cmd/ad/.ar/sa.getBib/.ps/N/.c/6_0_69/.ce/7_0_3AB/.p/5_0_341/.d/0#7_0_3AB>

                    Eolas-2 is coming?

                    Comment

                    • Peter Michaux

                      #25
                      Re: createTextNode and IE7

                      Peter Michaux wrote:
                      >
                      Although the only browser I know of that won't use createTextNode is IE.

                      What does that code do in Safari (in fact, any mac browser) when called
                      with a insertScript('a lert("It worked")') ?
                      <snip>
                      What do the Mac browsers (and even NS6 Win) do with the code above I posted?
                      >
                      If you post some examples at a few different URLs then I can click them
                      in Safari 2.0.4 and if the issue is still interesting in a few weeks I
                      can also click them in Safari 1.3.9.
                      I've done most of the work to check out script insertion with
                      mainstream browsers and some exotics. See the tests and results



                      The bad news is neither script insertion method works with NN6. The
                      iCab failure is a worry because that is a current release. Even if iCab
                      isn't mainstream some equally lesser known browsers on portable devices
                      could have failure too. I don't know about Safari <2 yet. Later today.

                      It would seem bad to depend on an technique for use with XHR when NN6
                      isn't really ancient yet has XHR. The fact some rare XHR browsers can't
                      use this technique makes me nervous that depending on the technique
                      could cause a major backfire in the future.

                      The eval() technique works. It is part of the language so part of an
                      old standard. I think using eval is the conservative choice.

                      Peter

                      Comment

                      • Randy Webb

                        #26
                        Re: createTextNode and IE7

                        Peter Michaux said the following on 12/6/2006 4:32 PM:
                        Peter Michaux wrote:
                        >>Although the only browser I know of that won't use createTextNode is IE.
                        >>>
                        >>What does that code do in Safari (in fact, any mac browser) when called
                        >>with a insertScript('a lert("It worked")') ?
                        ><snip>
                        >>What do the Mac browsers (and even NS6 Win) do with the code above I posted?
                        >If you post some examples at a few different URLs then I can click them
                        >in Safari 2.0.4 and if the issue is still interesting in a few weeks I
                        >can also click them in Safari 1.3.9.
                        >
                        I've done most of the work to check out script insertion with
                        mainstream browsers and some exotics.
                        Can I impose on you to ask to test this page with the browsers not
                        listed there?

                        <URL: http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/index.html>

                        I edited it and added the browsers/OS that you have listed that aren't
                        on that page. They should show up with a blue background and "Untested"
                        in the boxes.
                        Firefox 2.0 WinXP - success on both.
                        Opera 9.0 WinXP - success on both.
                        Mozila 1.7.8 - success on both.

                        You can duplicate the results for IE6/XP for IE7/XP
                        The bad news is neither script insertion method works with NN6.
                        NN6 shouldn't be a concern as it is old enough that it isn't worth
                        worrying with. Netscape is up to 8.0 and NS users tend to parallel
                        Opera/Mozilla/Firefox users where they tend to keep it updated.
                        The iCab failure is a worry because that is a current release. Even if iCab
                        isn't mainstream some equally lesser known browsers on portable devices
                        could have failure too. I don't know about Safari <2 yet. Later today.
                        iCab doesn't like my dynamic loading either. Does it support XHR though?
                        It would seem bad to depend on an technique for use with XHR when NN6
                        isn't really ancient yet has XHR. The fact some rare XHR browsers can't
                        use this technique makes me nervous that depending on the technique
                        could cause a major backfire in the future.
                        No more so than depending on XHR to start with. If you are worried about
                        failure with executing the scripts because of an old browser then you
                        need to worry about using XHR before then.
                        The eval() technique works. It is part of the language so part of an
                        old standard. I think using eval is the conservative choice.
                        Then why not just make all your code strings and eval it? Seriously,
                        eval has its problems and it may solve some problems but it introduces
                        problems of its own as well.


                        --
                        Randy
                        Chance Favors The Prepared Mind
                        comp.lang.javas cript FAQ - http://jibbering.com/faq
                        Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

                        Comment

                        • Peter Michaux

                          #27
                          Re: createTextNode and IE7

                          Randy Webb wrote:
                          >
                          Can I impose on you to ask to test this page with the browsers not
                          listed there?
                          >
                          <URL: http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/index.html>
                          >
                          I edited it and added the browsers/OS that you have listed that aren't
                          on that page. They should show up with a blue background and "Untested"
                          in the boxes.
                          Ok. I clicked each of the buttons and refreshed between each click. If
                          I saw an alert I called it a success.

                          Results are appended at the bottom of this email for the browsers I
                          have. I checked Konq by chatting on irc #kde so couldn't check now.

                          BTW, where did you get OS X 10.6.2 ?!?!?!
                          The bad news is neither script insertion method works with NN6.
                          >
                          NN6 shouldn't be a concern as it is old enough that it isn't worth
                          worrying with. Netscape is up to 8.0 and NS users tend to parallel
                          Opera/Mozilla/Firefox users where they tend to keep it updated.
                          >
                          The iCab failure is a worry because that is a current release. Even if iCab
                          isn't mainstream some equally lesser known browsers on portable devices
                          could have failure too. I don't know about Safari <2 yet. Later today.
                          >
                          iCab doesn't like my dynamic loading either. Does it support XHR though?
                          Yes iCab 3.0.3 does support XHR

                          I don't know what your tests are doing compared to mine but my simple
                          script insertions failed in iCab. Two of your tests worked.

                          It would seem bad to depend on an technique for use with XHR when NN6
                          isn't really ancient yet has XHR. The fact some rare XHR browsers can't
                          use this technique makes me nervous that depending on the technique
                          could cause a major backfire in the future.
                          >
                          No more so than depending on XHR to start with.
                          Yes more than depending on XHR. Actually that was my point. If NN6 has
                          XHR but can't insert scripts then the insert scripts is an added
                          limitation on the number of supported browsers. Again, I don't know
                          what is going on with your iCab tests but it is almost certain there
                          will be browsers that can't insert scripts but do have eval, don't you
                          think?

                          Really NN6 isn't my biggest concern. It is newer browsers in mobil
                          devices.

                          If you are worried about
                          failure with executing the scripts because of an old browser then you
                          need to worry about using XHR before then.
                          Agreed

                          The eval() technique works. It is part of the language so part of an
                          old standard. I think using eval is the conservative choice.
                          >
                          Then why not just make all your code strings and eval it? Seriously,
                          eval has its problems and it may solve some problems but it introduces
                          problems of its own as well.
                          But I'm scared :S Scared of deploying a novel non-standard technique
                          that makes programming easier but that might break when another
                          standard technique that rarely involves any tricky programming is
                          almost guarrenteed success. Imagine having to explain that to the boss.
                          Two particular eff words might follow.

                          Peter


                          // ------------------------------------------------------------------

                          <tr>
                          <td class="PC" width="160px">N etscape 8.0.4</td>
                          <td class="PC" width="110px">W in XP</td>
                          <td class="no">No</td>
                          <td class="no">No</td>
                          <td class="yes">Yes </td>
                          </tr>
                          <tr>
                          <td class="PC" width="160px">N etscape 7.0</td>
                          <td class="PC" width="110px">W in XP</td>
                          <td class="no">No</td>
                          <td class="no">No</td>
                          <td class="yes">Yes </td>
                          </tr>
                          <tr>
                          <td class="PC" width="160px">N etscape 6.0</td>
                          <td class="PC" width="110px">W in XP</td>
                          <td class="no">No</td>
                          <td class="no">No</td>
                          <td class="no">No</td>
                          </tr>
                          <tr>
                          <td class="MAC">Cam ino 1.0.3</td>
                          <td class="MAC">Mac OS 10.4.8</td>
                          <td class="no">No</td>
                          <td class="no">No</td>
                          <td class="yes">Yes </td>
                          <td></td>
                          </tr>
                          <tr>
                          <td class="MAC">Ope ra 9.02</td>
                          <td class="MAC">Mac OS 10.4.8</td>
                          <td class="yes">Yes </td>
                          <td class="no">No</td>
                          <td class="yes">Yes </td>
                          <td></td>
                          </tr>
                          <tr>
                          <td class="MAC">Shi ira 1.2.2</td>
                          <td class="MAC">Mac OS 10.4.8</td>
                          <td class="no">No</td>
                          <td class="no">No</td>
                          <td class="yes">Yes </td>
                          <td></td>
                          </tr>
                          <tr>
                          <td class="MAC">Sun rise 0.89</td>
                          <td class="MAC">Mac OS 10.4.8</td>
                          <td class="no">No</td>
                          <td class="no">No</td>
                          <td class="yes">Yes </td>
                          <td></td>
                          </tr>
                          <tr>
                          <td class="MAC">Fir efox 2.0 </td>
                          <td class="MAC">Mac OS 10.4.8</td>
                          <td class="no">No</td>
                          <td class="no">No</td>
                          <td class="yes">Yes </td>
                          <td></td>
                          </tr>
                          <tr>
                          <td class="MAC">Fir efox 1.5.0.8</td>
                          <td class="MAC">Mac OS 10.4.8</td>
                          <td class="no">No</td>
                          <td class="no">No</td>
                          <td class="yes">Yes </td>
                          <td></td>
                          </tr>
                          <tr>
                          <td class="MAC">iCa b 3.0.3 </td>
                          <td class="MAC">Mac OS 10.4.8</td>
                          <td class="no">No</td>
                          <td class="yes">Yes </td>
                          <td class="yes">Yes </td>
                          <td></td>
                          </tr>

                          Comment

                          • Peter Michaux

                            #28
                            Re: createTextNode and IE7

                            Peter Michaux wrote:
                            Randy Webb wrote:
                            I don't know what your tests are doing compared to mine but my simple
                            script insertions failed in iCab. Two of your tests worked.
                            I just read your source. I see that you are testing loading js files on
                            the fly vs. I was testing script insertion: apples and oranges.

                            Peter

                            Comment

                            • Randy Webb

                              #29
                              Re: createTextNode and IE7

                              Peter Michaux said the following on 12/6/2006 11:59 PM:
                              Randy Webb wrote:
                              >Can I impose on you to ask to test this page with the browsers not
                              >listed there?
                              >>
                              ><URL: http://members.aol.com/_ht_a/hikksnotathome/loadJSFile/index.html>
                              >>
                              >I edited it and added the browsers/OS that you have listed that aren't
                              >on that page. They should show up with a blue background and "Untested"
                              >in the boxes.
                              >
                              Ok. I clicked each of the buttons and refreshed between each click. If
                              I saw an alert I called it a success.
                              >
                              Results are appended at the bottom of this email for the browsers I
                              have. I checked Konq by chatting on irc #kde so couldn't check now.
                              >
                              BTW, where did you get OS X 10.6.2 ?!?!?!
                              I was being pshycic :) Thank you for pointing out my typo error in a
                              copy paste. Not sure how I managed that.
                              >>The bad news is neither script insertion method works with NN6.
                              >NN6 shouldn't be a concern as it is old enough that it isn't worth
                              >worrying with. Netscape is up to 8.0 and NS users tend to parallel
                              >Opera/Mozilla/Firefox users where they tend to keep it updated.
                              >>
                              >>The iCab failure is a worry because that is a current release. Even if iCab
                              >>isn't mainstream some equally lesser known browsers on portable devices
                              >>could have failure too. I don't know about Safari <2 yet. Later today.
                              >iCab doesn't like my dynamic loading either. Does it support XHR though?
                              >
                              Yes iCab 3.0.3 does support XHR
                              >
                              I don't know what your tests are doing compared to mine but my simple
                              script insertions failed in iCab. Two of your tests worked.
                              createElement test - uses createElement to create a script block and set
                              its .src property to load a .js file

                              change innerHTML - changes the innerHTML of a div tag to load a .js file

                              change source - changes the .src property of an existing script block
                              >
                              >>It would seem bad to depend on an technique for use with XHR when NN6
                              >>isn't really ancient yet has XHR. The fact some rare XHR browsers can't
                              >>use this technique makes me nervous that depending on the technique
                              >>could cause a major backfire in the future.
                              >No more so than depending on XHR to start with.
                              >
                              Yes more than depending on XHR. Actually that was my point. If NN6 has
                              XHR but can't insert scripts then the insert scripts is an added
                              limitation on the number of supported browsers.
                              If the string from an XHR requests has a script block in it, and you
                              insert it via innerHTML, then the script block gets loaded and executed
                              in early Netscape 6. Not sure what version of NS6 that changed in though.
                              Again, I don't know what is going on with your iCab tests but it is
                              almost certain there will be browsers that can't insert scripts but
                              do have eval, don't you think?
                              I don't think there is, I am pretty positive there are some around. But
                              the same goes for XHR where there will be browsers that support loading
                              scripts but don't support XHR. Its a tradeoff.
                              Really NN6 isn't my biggest concern. It is newer browsers in mobil
                              devices.
                              How many mobile devices support XHR though?
                              >>The eval() technique works. It is part of the language so part of an
                              >>old standard. I think using eval is the conservative choice.
                              >Then why not just make all your code strings and eval it? Seriously,
                              >eval has its problems and it may solve some problems but it introduces
                              >problems of its own as well.
                              >
                              But I'm scared :S Scared of deploying a novel non-standard technique
                              that makes programming easier but that might break when another
                              standard technique that rarely involves any tricky programming is
                              almost guarrenteed success. Imagine having to explain that to the boss.
                              Two particular eff words might follow.
                              My point was that just because something works doesn't mean you should
                              do it that way. In the end eval may be the most reliable way to go but
                              until then, I am still working on this approach to go with my loadJSFile
                              function :)

                              <snip>
                              --
                              Randy
                              Chance Favors The Prepared Mind
                              comp.lang.javas cript FAQ - http://jibbering.com/faq
                              Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

                              Comment

                              • Randy Webb

                                #30
                                Re: createTextNode and IE7

                                Peter Michaux said the following on 12/7/2006 12:07 AM:
                                Peter Michaux wrote:
                                >Randy Webb wrote:
                                >
                                >I don't know what your tests are doing compared to mine but my simple
                                >script insertions failed in iCab. Two of your tests worked.
                                >
                                I just read your source. I see that you are testing loading js files on
                                the fly vs. I was testing script insertion: apples and oranges.
                                Yes, I am loading files on the fly. I am probably going to add something
                                along the lines of your test page results to it where it also indicates
                                support (or lack of) for changing the .text property of a script element
                                and the support for createTextNode

                                --
                                Randy
                                Chance Favors The Prepared Mind
                                comp.lang.javas cript FAQ - http://jibbering.com/faq
                                Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

                                Comment

                                Working...