Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IE 7 Error - Works fine in FF | Javascript with XSL, XML

    This page will not display properly in IE7:
    http://www.puzuki.com/nuzuki/motion_art/video_index.xml
    This is the XSL file with the JavaScript:
    http://www.puzuki.com/nuzuki/motion_art/motion_art.xsl

    It works fine and dandy in FF. I just don't understand. I know it's a JS error, but I've spent HOURS trying to figure it out with no luck. Can anybody that is a little more advanced help me with this.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Add semicolons after the brackets.

    };function

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not sure why it works in FF. Typically you need

    <![CDATA[ ... ]]>

    Around reserved characters otherwise it escapes them and

    if (i < 0) {

    becomes

    if (i &lt; 0) {

    which has errors in compilation time.

    I've never tried what you are doing where the js is created by xsl. Looks like it might be browser dependent though.

    david_kw

  • #4
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's not pretty but try this test out. It seems to work in FF2 and IE7. I have no idea if this example helps in your situation but it sure is interesting.

    note: notice I didn't put the "if (" in CDATA and it worked anyway since it has no reserved characters.

    js_create_test.xsl
    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <html>
          <head>
            <title>Test JS from XSL</title>
            <script type="text/javascript">
              <![CDATA[
              function doIt(s) {
                var adiv = document.getElementById("adiv");
                adiv.innerHTML = s;
              }
              function olderThan5() {
                var s = "";
              ]]>
    
              <xsl:for-each select="dogs/dog">
                if ( <xsl:value-of select="@age" /> <![CDATA[ >= 5 ) {
                  s += "]]><xsl:value-of select="@name" /><![CDATA[ is at least 5<br>";
                }]]>
              </xsl:for-each>
                
              <![CDATA[
                doIt(s);
              }
              ]]>
            </script>
          </head>
          <body>
            <button onclick="olderThan5()">Do it</button>
            <div id="adiv"> </div>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    js_create_test.xml
    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <?xml-stylesheet href="js_create_test.xsl" type="text/xsl" ?>
    <dogs>
      <dog name="Spot" age="3" />
      <dog name="Rover" age="5" />
      <dog name="Fido" age="7" />
    </dogs>
    and in FF2 generates this code

    Code:
    <html><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><title>Test JS from XSL</title><script type="text/javascript">
              
              function doIt(s) {
                var adiv = document.getElementById("adiv");
                adiv.innerHTML = s;
              }
              function olderThan5() {
                var s = "";
              
    
              
                if ( 3  >= 5 ) {
                  s += "Spot is at least 5<br>";
                }
              
                if ( 5  >= 5 ) {
                  s += "Rover is at least 5<br>";
                }
              
                if ( 7  >= 5 ) {
                  s += "Fido is at least 5<br>";
                }
              
                
              
                doIt(s);
              }
              
            </script></head><body><button onclick="olderThan5()">Do it</button><div id="adiv">Rover is at least 5<br>Fido is at least 5<br></div></body></html>
    david_kw

  • #5
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I will try each of these suggestions in turn and get back to everybody. Thank you SOOOO much. I am an amateur programmer (art is my expertise) and I have NO idea what I'm doing. I'm surprised I got this far, honestly. Thanks!

  • #6
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am sorry to say this did not work, as it was the easiest solution. I did leave the semicolons after the brackets, as this seems good practice. Perhaps there is something else wrong?

    Quote Originally Posted by A1ien51 View Post
    Add semicolons after the brackets.

    };function

    Eric

  • #7
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Unfortunately, this solution did not work for either FF or IE. Perhaps something else will work. I'm stumped.

    Quote Originally Posted by david_kw View Post
    It's not pretty but try this test out. It seems to work in FF2 and IE7. I have no idea if this example helps in your situation but it sure is interesting.

    note: notice I didn't put the "if (" in CDATA and it worked anyway since it has no reserved characters.

    js_create_test.xsl
    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
        <html>
          <head>
            <title>Test JS from XSL</title>
            <script type="text/javascript">
              <![CDATA[
              function doIt(s) {
                var adiv = document.getElementById("adiv");
                adiv.innerHTML = s;
              }
              function olderThan5() {
                var s = "";
              ]]>
    
              <xsl:for-each select="dogs/dog">
                if ( <xsl:value-of select="@age" /> <![CDATA[ >= 5 ) {
                  s += "]]><xsl:value-of select="@name" /><![CDATA[ is at least 5<br>";
                }]]>
              </xsl:for-each>
                
              <![CDATA[
                doIt(s);
              }
              ]]>
            </script>
          </head>
          <body>
            <button onclick="olderThan5()">Do it</button>
            <div id="adiv"> </div>
          </body>
        </html>
      </xsl:template>
    </xsl:stylesheet>
    js_create_test.xml
    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <?xml-stylesheet href="js_create_test.xsl" type="text/xsl" ?>
    <dogs>
      <dog name="Spot" age="3" />
      <dog name="Rover" age="5" />
      <dog name="Fido" age="7" />
    </dogs>
    and in FF2 generates this code

    Code:
    <html><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><title>Test JS from XSL</title><script type="text/javascript">
              
              function doIt(s) {
                var adiv = document.getElementById("adiv");
                adiv.innerHTML = s;
              }
              function olderThan5() {
                var s = "";
              
    
              
                if ( 3  >= 5 ) {
                  s += "Spot is at least 5<br>";
                }
              
                if ( 5  >= 5 ) {
                  s += "Rover is at least 5<br>";
                }
              
                if ( 7  >= 5 ) {
                  s += "Fido is at least 5<br>";
                }
              
                
              
                doIt(s);
              }
              
            </script></head><body><button onclick="olderThan5()">Do it</button><div id="adiv">Rover is at least 5<br>Fido is at least 5<br></div></body></html>
    david_kw

  • #8
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Tried all these solutions and none of them worked.
    I still need help with this. Thanks SO much in advance.

  • #9
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    I can view the page just fine in IE 7. What exactly is it that is not working.

    Ehh, NM I see the js error.

    It's be wise to update your examples with your attempts at resolving the issue. The problems mentioned thus far are still most likely what is causing it to break, so seeing how you went about implementing the suggestions given might clue someone in.

    Basscyst
    Last edited by Basscyst; 12-06-2006 at 01:10 AM.
    Helping to build a bigger box. - Adam Matthews

  • #10
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Basscyst:

    I cannot get the video to load as it does in FF. Does the video load for you?

    ***
    ---
    NM - just read your NM.

  • #11
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Basscyst:

    So I've posted the solutions used so far.

    Solution #1:
    Works fine in FF but not in IE
    Adding semicolons after brackets:
    http://www.puzuki.com/nuzuki/motion_art/video_index.xml

    Solution #2:
    Does not work for FF or IE
    Adding CDATA tags
    http://www.puzuki.com/nuzuki/motion_...-cdata_fix.xml

  • #12
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Weird. My tests suggest that this line is the culprit:

    <html xmlns="http://www.w3.org/1999/xhtml">

    Try changing that to:

    <html>

    I had to make a lot of changes to narrow it down. I'm still not totally clear why that would be a problem.

    Plus I doubt this clears up all the problems. But it does appear to stop escaping the javascript code in IE this way. So hopefully it is a step in the right direction.

    david_kw

  • #13
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    david_kw:

    This didn't fix the problem that I could see, but it seems best practice to leave out the xmlns="http://www.w3.org/1999/xhtml". The page is still functional in FF, but not IE. :

    http://www.puzuki.com/nuzuki/motion_...x-no_xmlns.xml



    Quote Originally Posted by david_kw View Post
    Weird. My tests suggest that this line is the culprit:

    <html xmlns="http://www.w3.org/1999/xhtml">

    Try changing that to:

    <html>

    I had to make a lot of changes to narrow it down. I'm still not totally clear why that would be a problem.

    Plus I doubt this clears up all the problems. But it does appear to stop escaping the javascript code in IE this way. So hopefully it is a step in the right direction.

    david_kw

  • #14
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When I click on that link I see:

    <html xmlns="http://www.w3.org/1999/xhtml">

    and I don't see the CDATA. It looks like your original source again.

    david_kw

  • #15
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    david_kw:

    The correct page is up now. I must have done something in error. IE & FF are both displaying empty white boxes where there is supposed to be content. Now this seems like a step in the right direction.

    http://www.puzuki.com/nuzuki/motion_...x-no_xmlns.xml

    http://www.puzuki.com/nuzuki/motion_...t-no_xmlns.xsl


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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