www.webdeveloper.com
Results 1 to 15 of 15

Thread: FF XHTML script not working

  1. #1
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471

    FF XHTML script not working

    <script type="text/javascript">
    //<![CDATA[
    sw=screen.width;
    sh=screen.height;
    document.write("<img width='1' height='1' src='http://sts.siteuri.ro/counter/counter.php?screen="+sw+"x"+sh+"' />");
    //]]>
    </script>
    <noscript>
    <img height="1" width="1" src="http://sts.siteuri.ro/counter/counter.php?screen=nojs" />
    </noscript>

    For some reason, if i send the page as application/xhtml+xml, FF calls the noscript image, even if Javascript is enabled. Declaring the Javascript as application/x-javascript doesn't help.

    Is there any Javascript / XHTML issue that I'm missing here?

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    Use HTML 4.01 strict; it's much better.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Feb 2005
    Location
    USA
    Posts
    1,534
    plus, if you dont want to show the image (as it seems) but rather just make the http request then you should use this:
    Code:
    <script type="text/javascript">
    //<![CDATA[
    var sw=screen.width;
    var sh=screen.height;
    vra iMa=new Image();
    iMa.src='http://sts.siteuri.ro/counter/counter.php?screen="+sw+"x"+sh+";
    //]]>
    </script>
    <noscript>
    <img height="1" width="1" src="http://sts.siteuri.ro/counter/counter.php?screen=nojs" />
    </noscript>

  4. #4
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471
    Quote Originally Posted by Charles
    Use HTML 4.01 strict; it's much better.
    Not this debate again...

    What if I want to use XForms, XSLT or PHP's XML parser? What do I do then, rebuild my site?

    XHTML is cool, XHTML is the future. Plus I like my pages braking when I forget a tag.
    Last edited by amazing_andr3; 04-08-2005 at 07:40 AM.

  5. #5
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    If you are serving your page as real XHTML then it shouldn't be displaying at all unless you are specifying an XSLT stylesheet. Perhaps that's where the problem is. You aren't properly transforming the SCRIPT element.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  6. #6
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471
    What's with this error that I get?

    Error: uncaught exception: [Exception... "Object cannot be created in this context" code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)" location: "http://localhost/www/ Line: 158"]

  7. #7
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    Post the URL or switch to HTML.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  8. #8
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654

  9. #9
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471
    Quote Originally Posted by Fang
    Oh... so THAT was the problem...

    BigMoosie's preloading seems to work though... thanks BigMoosie.

    Unfortunately FF calls the <noscript> image as well so this is still not a working script.
    Last edited by amazing_andr3; 04-08-2005 at 04:55 PM.

  10. #10
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    Post the URL.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  11. #11
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471
    Quote Originally Posted by Charles
    Post the URL.
    the URI is either of my sites in my sig

  12. #12
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    And with one are you having trouble?
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  13. #13
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471
    Quote Originally Posted by Charles
    And with one are you having trouble?
    For example, this is what I got from your visit:

    11155 70.16.8.101 Firefox 1.0.2 direct hit 1112993950 index.php www.siteuri.ro nojs


    11154 70.16.8.101 Firefox 1.0.2 direct hit 1112993950 index.php www.siteuri.ro 1024x768

    (i.e. id ip agent referrer time page site screen)

    See, both images have been called so it's logged the same visit twice...

    Look for the JS at the end of the file.

  14. #14
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    The script is incorrectly escaped; for xhtml and (x)html browsers.
    Use an external link to avoid the problem.

  15. #15
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471
    Quote Originally Posted by Fang
    The script is incorrectly escaped; for xhtml and (x)html browsers.
    Use an external link to avoid the problem.
    I had an even bigger problem as robots do not go after images and they would not be logged. The changes I made to solve that also mean I can get all the information without using the <noscript> tag. That solves all my problems. Thanks again.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles