lilman Posted December 30, 2006 Share Posted December 30, 2006 I wrote this script and I don't see what is wrong with it. Here is the code<html><head><title><script type="text/javascript">function displayText(){ document.write("You're using JavaScript");}</script></title></head><body onMouseDown="displayText()"><h1> <br /><input name="color" type="button" onclick="document.bgcolor='pink'"></h1></body></html>and here is the error I get when I run it:Line: 12Char: 1Error: Object exceptedCode: 0 Link to comment https://forums.phpfreaks.com/topic/32237-onclick-and-onload/ Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 maybe you shouldn't be putting a <script> tag inside your <title> tag?[quote author=http://validator.w3.org]Error Line 4 column 30: document type does not allow element "SCRIPT" here.[/quote] Link to comment https://forums.phpfreaks.com/topic/32237-onclick-and-onload/#findComment-149635 Share on other sites More sharing options...
lilman Posted December 30, 2006 Author Share Posted December 30, 2006 thanks, boy do I feel silly. there is this code, now it doesn't produce an error notification but it doesn't change the bgcolor. <input name="color" type="button" onMouseDown="document.bgcolor='pink'">is there something wrong there? Link to comment https://forums.phpfreaks.com/topic/32237-onclick-and-onload/#findComment-149649 Share on other sites More sharing options...
michaellunsford Posted December 30, 2006 Share Posted December 30, 2006 a few possibilities. 1. "onmousedown" is supposed to be all lowercase.2. document.bgColor is NOT supposed to be all lowercase.3. onMouseDown -- isn't that flash? I'd use onclick.[code]onclick="document.bgColor='pink';"[/code] Link to comment https://forums.phpfreaks.com/topic/32237-onclick-and-onload/#findComment-149668 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.