W3C Validator Fehler: document type does not allow element "a" here

S

sevY

N'amd zusammen :)

Kurz und schmerzlos:

W3C Validator Fehler: document type does not allow element "a" here

Was hab ich schlimmes getan? Und wenn, was kann ich als alternative machen?


PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="expires" content="14" />
<meta name="description" content=x"" />
<meta name="keywords" lang="de" content="x" />
<meta name="robots" content="all" />
<meta name="revisit-after" content="14 days" />
<meta name="author" content="x" />
<meta name="publisher" content="x" />
<link rel="stylesheet" type="text/css" href="default.inc.css" />
<link rel="shortcut icon" type="image/ico" href="img/favicon.ico" />
<script language="javascript" type="text/javascript" src="function.inc.js"></script>
<title>x</title>
</head>
<body>
<div class="main">
    <div class="content">
        <div class="center">
            <script language="javascript" type="text/javascript">            
                if(hasRightVersion) 
                    {
                    document.write('<a href="flash.php" target="_self" title="Click to enter"><img src="img/enter.gif" alt="enter" /></a>');
                    } 
                else 
                    {
                    document.write('<a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_self" title="Get Macromedia Flashplayer"><img src="img/get_flash_player.gif" alt="Get Macromedia Flashplayer" /></a>');
                    }
            </script>
            <noscript>
                <img src="img/enable_javascript.gif" alt="Enable JavaScript" />
            </noscript>
            <div class="bottom">
                <a href="impressum.php" target="_self" title="Impressum">
                    <img src="img/impressum.gif" alt="Impressum" />
                </a>
            </div>
        </div>
    </div>
</div>
</body>
</html>
 
W3C sprach:

Line 23, column 93: document type does not allow element "a" here

...target="_self" title="Click to enter"><img src="img/enter.gif" alt="enter" />



The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).


One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).



?



Line 27, column 184: document type does not allow element "a" here

...f" title="Get Macromedia Flashplayer"><img src="img/get_flash_player.gif" alt
 
Ok.


document.write() und XHTML vertragen sich nicht.

Das hier ist die Lösung:

PHP:
<?php require_once('head.inc.php'); ?>
<body>
<div class="main">
    <div class="content">
        <div id="write" class="center">
            <script language="javascript" type="text/javascript">   
            if(hasRightVersion) 
                {
                if(document.createElementNS)
                    {
                    var enter=document.createElementNS("http://www.w3.org/1999/xhtml", "input");
                    enter.setAttribute("type", "image");
                    enter.setAttribute("src", "img/enter.gif");   
                    enter.setAttribute("onclick", "javascript:window.location.href='flash.php'");     
                    document.getElementById("write").appendChild(enter);
                    }
                }
            else
                {
                if(document.createElementNS)
                    {
                    var plugin=document.createElementNS("http://www.w3.org/1999/xhtml", "input");
                    plugin.setAttribute("type", "image");
                    plugin.setAttribute("src", "img/get_flash_player.gif");   
                    plugin.setAttribute("onclick", "javascript:window.location.href='http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash'");     
                    document.getElementById("write").appendChild(plugin);
                    }
                }
            </script>
            <noscript>
                <img src="img/enable_javascript.gif" alt="Enable JavaScript" />
            </noscript>
            <div class="bottom">
                <a href="impressum.php" target="_self" title="Impressum">
                    <img src="img/impressum.gif" alt="Impressum" />
                </a>
            </div>
        </div>
    </div>
</div>
</body>
</html>

Yves
 
Zurück
Oben Unten