4 replies [Last post]
thatsgame1
thatsgame1's picture
Offline
Enthusiast
Tallahassee, FL
Last seen: 15 years 5 weeks ago
Tallahassee, FL
Joined: 2004-11-06
Posts: 69
Points: 0

Hi guys,

Anyone know how I can get

<script type="text/javascript" language="JavaScript">
							<!-- Begin
								if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {

									var url="http://www.fsus.fsu.edu/FSUSNew";
									var title="Florida State Univerity Schools";

									document.write('<A HREF="javascript:window.ext');
									document.write('ernal.AddFavorite(url,title);" ');
									document.write('class="bottom" onMouseOver=" window.status=');
									document.write("'Bookmark our website!'; return true ");
									document.write('"onMouseOut=" window.status=');
									document.write("' '; return true ");
									document.write('">Bookmark Us!</a>');
			
									}
								else {
									var msg = "Bookmark Us!";
								if(navigator.appName == "Netscape") msg += " (CTRL-D)";
									document.write(msg);
									}
							// End -->
							
							</SCRIPT>

To validate in HTML 4.01 Transitional? I get end tag for element "A" which is not open error.

Thank you

Tags:
roytheboy
roytheboy's picture
Offline
Guru
North Wales, UK
Last seen: 9 years 28 weeks ago
North Wales, UK
Timezone: GMT+1
Joined: 2004-09-18
Posts: 2233
Points: 41

Valid HTML 4.01 Transitional Bookmark Code

I know very little about javascript but from general coding knowledge I can see that you are using capital letters for your tags and properties where they should be lowercase (e.g. A, HREF, onMouseOut etc.), although I thought that was acceptable for HTML, and you seem to be mixing up your single and double quotes in the wrong way. Study the code that is generated by your script, particularly the quotes, and all should become clear.

Life's a b*tch and then you die!

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 6 days 18 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

Valid HTML 4.01 Transitional Bookmark Code

Hi thatsgame1,
It's probably a good idea to use lower case for the start and end of the tag.
I'm not sure if that's your error I thought case wasn't important till XHTML.

antibland
antibland's picture
Offline
Leader
Pittsburgh
Last seen: 14 years 4 weeks ago
Pittsburgh
Joined: 2005-01-17
Posts: 603
Points: 0

Valid HTML 4.01 Transitional Bookmark Code

thatsgame1,

I've reworked the code for you and it now validates. In the future, you really should avoid using uppercase for tags. It makes us standards people shiver in horror. Also, I like to create functions for little jobs when I can. It will keep your code a lot cleaner and easier to update in the future.

The main reason your code didn't validate under the 4.01 doctype is because you need backslash your forward slashes whenever you are within <script></script>

Your closing <a></a> tag had to look like this to work:

<\/a>

Here's the reworked code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<title></title> 
 <script type="text/javascript"> 
  
 		// globals 
 
		var url="http://www.fsus.fsu.edu/FSUSNew"; 
      var title="Florida State Univerity Schools"; 
  
 		// functions 
 
       function addFav() { 
			window.external.AddFavorite(url,title); 
		} 
		 
		function setStatus(statText) { 
			window.status=statText; 
		} 
		 
        if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {	 
	        document.write('<a href="#" onclick="addFav()" class="bottom"'); 
            document.write('onmouseover="setStatus(\'Bookmark our website\'); return true"'); 
            document.write('onmouseout="setStatus(\'\'); return true">'); 
            document.write('Bookmark Us!'); 
			document.write('<\/a>'); 
		} 
        else { 
        	var msg = "Bookmark Us!"; 
        	if(navigator.appName == "Netscape") msg += " (CTRL-D)"; 
            	document.write(msg); 
        }             
</script> 
</head> 
 
<body> 
</body> 
</html>

thatsgame1
thatsgame1's picture
Offline
Enthusiast
Tallahassee, FL
Last seen: 15 years 5 weeks ago
Tallahassee, FL
Joined: 2004-11-06
Posts: 69
Points: 0

Valid HTML 4.01 Transitional Bookmark Code

Hello antibland

Thank you for taking the time to help me. I really appreciate it and thanks for the advice.

Thanks again,

Andrew