Loading ...
Sorry, an error occurred while loading the content.

Logging - works in Fireox but not Safari

Expand Messages
  • Rush Manbert
    Hi, The code below is a simple example of my attempt to use the logging widget. I got here because I started out more ambitiously with the autocomplete, but
    Message 1 of 2 , May 30, 2007
    • 0 Attachment
      Hi,

      The code below is a simple example of my attempt to use the logging
      widget. I got here because I started out more ambitiously with the
      autocomplete, but when that didn't work I tried adding logging, but that
      didn't work either.

      Anyway, the code below works as expected in Firefox, but only displays
      the first alert in Safari. The Safari JavaScript Console says:

      TypeError - Undefined value
      file:///Users/rmanbert/blah/blah/a.xhtml Line: 12

      Here is the code:

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
      <!-- Required CSS -->
      <link type="text/css" rel="stylesheet"
      href="http://yui.yahooapis.com/2.2.2/build/logger/assets/logger.css" />

      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>XXX.xhtm</title>
      </head>
      <body>

      <!-- Script code starts here -->

      <!-- Dependencies -->
      <script type="text/javascript"
      src="http://yui.yahooapis.com/2.2.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>


      <!-- OPTIONAL: Drag and Drop (not required if not enabling drag and
      drop) -->
      <script type="text/javascript"
      src="http://yui.yahooapis.com/2.2.2/build/dragdrop/dragdrop-min.js"></script>


      <!-- Source file -->
      <script type="text/javascript"
      src="http://yui.yahooapis.com/2.2.2/build/logger/logger-min.js"></script>


      <script type="text/javascript">
      <![CDATA[
      alert ("Creating log reader");

      var myLogReader = new
      YAHOO.widget.LogReader(null,{top:"10%",right:"10px"});
      alert ("Made log reader");
      myLogReader.show();
      YAHOO.log ("Here's a message");
      alert ("message sent");
      ]]>
      </script>
      </body>
      </html>

      When I display the sample pages in Safari, they work, so I'm obviously
      doing something wrong. Can anyone please point out my error? I just
      can't see it.

      BTW, I have tried this code without the meta element and without the
      XHTML namespace declaration, and it doesn't change anything.

      Thanks,
      Rush
    • Rush Manbert
      ... I will answer my own question, just in case someone else stumbles over this. The actual problem was that the content shown above was in a file named
      Message 2 of 2 , Jun 22, 2007
      • 0 Attachment
        Rush Manbert wrote:
        > Hi,
        >
        > The code below is a simple example of my attempt to use the logging
        > widget. I got here because I started out more ambitiously with the
        > autocomplete, but when that didn't work I tried adding logging, but that
        > didn't work either.
        >
        > Anyway, the code below works as expected in Firefox, but only displays
        > the first alert in Safari. The Safari JavaScript Console says:
        >
        > TypeError - Undefined value
        > file:///Users/rmanbert/blah/blah/a.xhtml Line: 12
        >
        > Here is the code:
        >
        > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        > "http://www.w3.org/TR/html4/strict.dtd">
        > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        > <head>
        > <!-- Required CSS -->
        > <link type="text/css" rel="stylesheet"
        > href="http://yui.yahooapis.com/2.2.2/build/logger/assets/logger.css" />
        >
        > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        > <title>XXX.xhtm</title>
        > </head>
        > <body>
        >
        > <!-- Script code starts here -->
        >
        > <!-- Dependencies -->
        > <script type="text/javascript"
        > src="http://yui.yahooapis.com/2.2.2/build/yahoo-dom-event/yahoo-dom-event.js"></script>
        >
        >
        > <!-- OPTIONAL: Drag and Drop (not required if not enabling drag and
        > drop) -->
        > <script type="text/javascript"
        > src="http://yui.yahooapis.com/2.2.2/build/dragdrop/dragdrop-min.js"></script>
        >
        >
        > <!-- Source file -->
        > <script type="text/javascript"
        > src="http://yui.yahooapis.com/2.2.2/build/logger/logger-min.js"></script>
        >
        >
        > <script type="text/javascript">
        > <![CDATA[
        > alert ("Creating log reader");
        >
        > var myLogReader = new
        > YAHOO.widget.LogReader(null,{top:"10%",right:"10px"});
        > alert ("Made log reader");
        > myLogReader.show();
        > YAHOO.log ("Here's a message");
        > alert ("message sent");
        > ]]>
        > </script>
        > </body>
        > </html>
        >
        > When I display the sample pages in Safari, they work, so I'm obviously
        > doing something wrong. Can anyone please point out my error? I just
        > can't see it.
        >
        > BTW, I have tried this code without the meta element and without the
        > XHTML namespace declaration, and it doesn't change anything.
        >

        I will answer my own question, just in case someone else stumbles over this.

        The actual problem was that the content shown above was in a file named
        test.xhtml, so the browser treated it as a XHTML file. (I'm trying to
        create a reduced test case for a grids layout problem, but the app where
        I see it is my own WebKit-based browser, which takes XHTML files as
        input. When I made the test file to feed to Safari, I gave it a xhtml
        extension out of habit.) There is a bug in WebKit (See
        <http://bugs.webkit.org/show_bug.cgi?id=12628>) that document.body does
        not work for XHTML files. That makes a bunch of stuff not work, and
        explains why YUI logging didn't work.

        My workaround was to rename the file as test.html. That makes
        document.body work.

        - Rush
      Your message has been successfully submitted and would be delivered to recipients shortly.