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

Thread: DHTML, IE, and DOCTYPE declaration

  1. #1
    Join Date
    Apr 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default DHTML, IE, and DOCTYPE declaration

    I haven't found any other threads on this issue in other forums, so my apologies in advance if this is a known issue that I'm not aware of. The following DHTML script, which creates a simple mouse trail, works great in Firefox and IE. However, if I add a DOCTYPE declaration, it does not work in IE, but still works fine in Firefox. Note that I've already tried changing the DOCTYPE version to 1.1, but no luck. Thanks in advance.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Mouse Trail</title>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
    </head>
    <body onmousemove="moveMouse(event)">
    <script type="text/javascript">
    /* <![CDATA[ */
    var trailInterval = 12;
    var yPosition = -10;
    var xPosition = -10;
    var animationStarted = false;
    for (i = 0; i < trailInterval; i++) {
    document.write("<div id='dots"+i+"' style='position:absolute;top:-10px;left:-10px;width:"+i/2+"px;height:"+i/2+"px;background:blue;font-size:"+i/2+"px'></div>");
    }
    function moveMouse(event) {
    if (!animationStarted) {
    animationStarted = true;
    animate();
    }
    xPosition = event.screenX + 10;
    if (navigator.appName == "Microsoft Internet Explorer")
    yPosition = event.screenY - 120;
    else if (navigator.appName == "Netscape")
    yPosition = event.screenY - 65;
    }
    function animate(){
    for (i = 0; i < trailInterval; i++){
    var temp1 = document.getElementById("dots"+i);
    if (i < trailInterval-1){
    var temp2 = document.getElementById("dots"+(i+1));
    temp1.style.top = temp2.style.top;
    temp1.style.left = temp2.style.left;
    }
    else {
    temp1.style.top = yPosition + "px";
    temp1.style.left = xPosition + "px";
    }
    }
    setTimeout("animate()",40);
    }
    /* ]]> */
    </script>
    </body>
    </html>

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Mouse Trail</title>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
    </head>
    should be

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Mouse Trail</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Because IE doesn't support XHTML yet.

    I doubt that will help with your problem, though (and you'd also have to revalidate a lot of your site).

    "Doesn't work" isn't an adequate description of a problem. What exactly goes wrong? What's the error you get?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Apr 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for replying so fast. Your suggestions was just to change the XHTML DOCTYPE declaration to an HTML DOCTYPE declaration, which unfortunately didn't do the trick. Let me know if you have any other ideas. Note that the code in my original posting is complete and doesn't require any external image files, so you can test it yourself - if you have nothing else to do . Thanks again.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Certainly we can, but since it's your problem, it's usually considered polite if you provide the information required to fix it If you can't for some (good) reason, say so and we'll do it.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Apr 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I suspect you are right in that IE probably just doesn't adequately support XHTML. But, I am using IE 7, so I'm curious as to why. Note that the code in my original posting is complete and doesn't require any external image files, so you can test it yourself. It should just display a simple mouse trail behind the cursor, but nothing shows up in IE 7 when the file includes the DOCTYPE declaration. I've tried using version 1.1 and transitional, but no lcuk.

  7. #7
    Join Date
    Apr 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Regarding your comment about it usually being considered polite to provide the information required to fix the problem - if I knew what the information was that is required to fix the problem, I wouldn't need to ask this forum, now would I?

  8. #8
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by drg View Post
    doesn't adequately support XHTML.
    Doesn't support at all. MS promised they would, and didn't (no suprise), and so a majority of the web is still error laden with bugs and hacks everywhere... XHTML would have done away with most of this, because as it is a facet of XML it displays errors in the document rather than try to render the page. I have the same problem, so i just send it with an html** content type header so it IE error corrects it into html. i don't reccommend this use, though.
    source anyways, if you really want to use it.
    PHP Code:
    <?php
    if (
      !
    strstr($_SERVER["HTTP_USER_AGENT"],"MSIE") ||
      
    strstr($_SERVER["HTTP_USER_AGENT"],"like MSIE") ||
      
    strstr($_SERVER["HTTP_USER_AGENT"],"Opera")
    ) {
      
    header("Content-type: application/xhtml+xml; charset=UTF-8");
      echo
    "<?xml version=\"1.0\"?>";
    } else {
      
    header("Content-type: text/html; charset=UTF-8");
      
    $fail TRUE;
    }
    error_reporting(E_ALL);
    $base "http://boxxertrumps.bo.funpic.org/";
    ?>
    EDIT: **actually, i just don't send it with an xhtml contype, sorry to confuse if you are.
    EDIT2: needed to send as UTF-8, b/c default is an ISO one i changed the code.
    Last edited by boxxertrumps; 04-26-2007 at 11:51 PM.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    EDIT: **actually, i just don't send it with an xhtml contype, sorry to confuse if you are.
    No, you do send it with an HTML content type. If you don't specify one, the PHP parser will use text/html automatically. However, as I said above, I don't think the DOCTYPE is the cause of the problem here.
    Regarding your comment about it usually being considered polite to provide the information required to fix the problem - if I knew what the information was that is required to fix the problem, I wouldn't need to ask this forum, now would I?
    As I've said above, you can tell us what the error is you get, how exactly it fails to work, and possibly other things.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Twey, I meant "I" as in, i didn't actively put the content type header in.
    I looked in Konqueror's document information window, and saw that instead of a UTF charset it was an ISO.
    fixed the code to send as text/html;UTF-8...
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

Bookmarks

Posting Permissions

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