Jess McKenzie
Jess McKenzie

Reputation: 8385

there is no attribute "onLoad"

Can anyone tell me why I am getting error when I am validating even through I have the correct doctype?

<!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" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- TemplateBeginEditable name="doctitle" -->
<title></title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<meta name="keywords" content="" />
<meta name="description" content="" />
<!-- TemplateEndEditable -->
<link href="../style.css" rel="stylesheet" type="text/css" />
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
    swfobject.registerObject("flashBanner", "9.0.0");
</script>
</head>

<body onLoad="InitCaptcha()">

Error

Line 21, Column 14: there is no attribute "onLoad"

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the element to incorporate flash media in a Web page, see the FAQ item on valid flash.

Upvotes: 3

Views: 5499

Answers (3)

rink.attendant.6
rink.attendant.6

Reputation: 46228

I realize the question has already been answered, but I'm going to add in that it is not a good idea to mix your XHTML and JavaScript (e.g. by using the onload event attribute).

You can use jQuery:

$(document).ready(function() {
    InitCaptcha();
});

Or you can use an event listener:

<script type="text/javascript">
    window.addEventListener('load', function() {
        'use strict';
        InitCaptcha();
    }, false);
</script>

Upvotes: 0

Edy Elwood
Edy Elwood

Reputation: 137

Since you're already using jquery, (which can be turned off) maybe you can try just using the javascript onload function... http://www.w3schools.com/jsref/event_onload.asp

Upvotes: 0

paly
paly

Reputation: 141

You have to change the onLoad attribute inside body to onload as XHTML is case-sensitive and it allows only lower-case letters for tags & attributes.

Upvotes: 10

Related Questions