Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: <script> blocks not triggered if they contain comments

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default <script> blocks not triggered if they contain comments

    I am loading tabs dynamically using:

    Code:
    t.getUpdateManager().loadScripts = true;
    t.setUrl('__linkblog.cfm', null, true);
    This all works, but i've discovered a little fault under IE. If the <script> block within the loaded frame contains something like:

    Code:
    <script>
    linkBlogTabs();
    </script>
    then all works beautifully. However if the script block has:

    Code:
    <script>&lt;!--
    linkBlogTabs();
    //--&gt;</script>
    then IE complains of an error, but FireFox works beautifully. (i can't seem to get the < > to render properly, but i think you get the gest)

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Surely "&lt;!-- " is not valid javascript, so it's bound to throw an error?

  3. #3

    Default

    okay, i am taking away my previous "genius" mantra from you animal

    I couldn't get < > to render properly in *this* forum software. So, please, assume that the Javascript is legal, with the correct < !-- -- > bits in place.

    I know you can do it ... dig deep now and think! ;-)

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Err.. I confoozed Aminal now.

    You mean you have "<--" as the first statement of your script? That no valid either!

  5. #5
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    6,956

    Default

    As Animal said, that's invalid JS and should indeed throw an error. BTW, to preserve HTML chars when posting check "Disable HTML".

  6. #6

    Default

    i didn't think this would be such a problem!!!

    guys here it is ... you are reading too literal! *thanks Jack the disable html works*

    <script><!--

    //--></script>

  7. #7
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    6,956

    Default

    <!-- doesn't look like JS to me.

    It could be stripped, but it would make more sense to strip it at the source. Do you need though comments in there?

  8. #8

    Default

    Quote Originally Posted by jacksloc
    <!-- doesn't look like JS to me.

    It could be stripped, but it would make more sense to strip it at the source. Do you need though comments in there?
    in the "old days" this is how you would write JS so browsers won't cough if they didn't support JS.

    The "new way" i guess would be this

    <script>// <![CDATA[

    // ]]></script>

  9. #9
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    That is old stuff. <script> is part of HTML4.

    If you suspect that your site may be used by people who for some reason eschew javascript (We are distributing a web-distributed application whose client UI runs under Javascript, so we mandate a Javascript-enabled platform, eg FF2+) then use the <noscript> tag.

  10. #10

    Default

    Quote Originally Posted by Animal
    That is old stuff. <script> is part of HTML4.
    okay, but don't you need to use CDATA if you technically want it to pass XHTML compliance?

Page 1 of 2 12 LastLast

Similar Threads

  1. Delete key not triggered by Keymap
    By mabushadi in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 3 Feb 2007, 1:53 PM
  2. Zoom In/Zoom Out Animation Comments Tutorial and/or Samples
    By Bobafart in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 29 Dec 2006, 5:36 PM
  3. "Popup" Window like Site Comments Box
    By drayru in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 14 Oct 2006, 12:09 AM

Posting Permissions

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