PDA

View Full Version : validating javascript onmouseover?


student101
09-12-2008, 10:27 AM
How to validate the javscript parts?
I know of the <!-- // and end in // --> or
//<![CDATA[ and end in //]]>
Using xhtml1-transitional 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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<a href="page.php" onmouseover="showtext('&lt;div style=&quot;padding-left:40px&quot;><a href=\'link1.php\'>Link1</a> | <a href=\'link2.php\'>Link2</a> | <a href=\'link3.php\'>Link3</a></div>','a', 'No')" onmouseout="hidetext()">Page1</a><img src="img/submenu.gif" alt=" " name="a" border="0" />
I managed to get it down to 29 Errors, 28 warning(s) , complaining about;
character "<" is the first character of a delimiter but occurred as data
Cheers

student101
10-28-2008, 07:37 AM
Tried changing;

' into &quot;
< into &lt;.
> into &gt;.This does not work, the other options I have are to code / find a CSS menu equal or figure out how to validate this.

Cheers

domedia
10-28-2008, 07:47 AM
Tried changing;

' into &quot;
< into &lt;.
> into &gt;.This does not works Then your browser is broke. This has been supported +10 years in all browsers. :(
Source?

student101
10-28-2008, 07:52 AM
How does this work? on your browser...

<a href="page.php" onmouseover="showtext(&quot;&lt;div style=&quot;padding-left:40px&quot;&gt;&lt;a href=\&quot;link1.php\&quot;&gt;Link1&lt;/a&gt; | &lt;a href=\&quot;link2.php\&quot;&gt;Link2&lt;/a&gt; | <a href=\&quot;link3.php\&quot;&gt;Link3&lt;/a&gt;&lt;/div&gt;&quot;,&quot;a&quot;, &quot;No&quot;)" onmouseout="hidetext()">Page1</a><img src="img/submenu.gif" alt=" " name="a" border="0" />


JavaScript Document;

//<![CDATA[
image1 = new Image
image2 = new Image
image1.src = 'img/submenu.gif'
image2.src = 'img/submenu_o.gif'
var baseopacity=0
function change(imagename, shop) {
document.a.src=image1.src
document.b.src=image1.src
document.c.src=image1.src
document.d.src=image1.src
if(shop=="Yes") {
document.e.src=image1.src
}
if (imagename == "a") {document.a.src=image2.src;
} else if (imagename == "b") {document.b.src=image2.src;
} else if (imagename == "c") {document.c.src=image2.src;
} else if (imagename == "d") {document.d.src=image2.src;
} else if (imagename == "e") {document.e.src=image2.src;
}
//document[imagename].src=image2.src
}
function showtext(thetext, imagename, shop){
if (!document.getElementById)
return
textcontainerobj=document.getElementById("menu_b")
browserdetect=textcontainerobj.filters? "ie" : typeof textcontainerobj.style.MozOpacity=="string"? "mozilla" : ""
document.getElementById("menu_b").innerHTML=thetext
change(imagename, shop)
instantset(100)
}
function notext(){
document.getElementById("menu_b").innerHTML=""
}
function hidetext(){
// instantset(baseopacity)
}
function instantset(degree){
if (browserdetect=="mozilla")
textcontainerobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
textcontainerobj.filters.alpha.opacity=degree
else if (document.getElementById && baseopacity==0)
document.getElementById("menu_b").innerHTML=""
}
//]]>