...

View Full Version : document type does not allow element "a" here



bebelie
06-13-2012, 05:13 PM
Good Day,

I am trying to validate my website where i am facing difficulties.
i have the following error:
Line 190, Column 67: document type does not allow element "a" here

7[1]='<a href="products.asp?action=color&amp;color=Multicolor">Multicolor<\/a>'



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).

my website is:
http://www.flowersjordan.com/indexme.asp
Please be noted that indexme.asp is different from the website , cause i will validate it before uploading the right index file.

can you try to help me please?

Best Regards
Elie.

SeattleMicah
06-13-2012, 05:21 PM
based on the code you pasted


…7[1]='<a href="products.asp?action=color&amp;color=Multicolor">Multicolor<\/a>'

I see a small error


<\/a>

should be


</a>

bebelie
06-13-2012, 05:31 PM
SOrry already fixed this one soo :
…7[1]='<a href="products.asp?action=coloramp;color=Multicolor">Multicolor</a>'

waiting for your next comment thank you in advance.

Best Regards
Elie

felgall
06-13-2012, 08:20 PM
You are feeding JavaScript into the HTML validator - JavaScript is not HTML and so will produce validation errors when you try to validate it as HTML.

Move your JavaScript into a separate file.

p-s. put back the \ in <\/ that JavaScript needs in order to not prematurely terminate the script when it sees </

bebelie
06-14-2012, 03:00 PM
Dear Stephen,

i would appreciate if you can help me in more details.

here is my html code:

<td><a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu7, '150px')" onmouseout="delayhidemenu()"><img src="upload2/<%=setimg(62)%>" width="125" height="31" border="0" /></a></td>

here is my javascript code:

var menu7 = new Array()
<%set objRSmenu7 = objConn.Execute ("SELECT * FROM xxx order by xxx")%>

<%
x = 1
do while not objRSmenu7.eof
%>
menu7[<%= x%>]='<a href="xxx.asp?action=color&amp;color=<%response.Write objRSmenu7("xxx")%>"><%response.Write objRSmenu7("xxx")%></a>'
<%
x = x + 1
objRSmenu7.movenext
loop%>

would you help me how can i do it?
as all this code is already in another file which is topmenu.asp
and this file is already included in the index.asp.

waiting to hearing you.

thank you in advance.

Have a peaceful day

Best Regards
Elie

felgall
06-14-2012, 08:11 PM
What does the actual HTML generated from that ASP look like? That is what the validator is looking at.

bebelie
06-17-2012, 09:11 AM
Here is the full asp code:



<%
strCN = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ="& server.mappath("db\eamsaoflo1.mdb") &""
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.open strCN

Function setcolor(id)
Set color = objConn.Execute("Select * from dyncolors where id = "&id&"")
If Not color.EOF Then
setcolor = color("color")
End If
End Function

Function setimg(id)
Set img = objConn.Execute("Select * from dynphoto where photo_id = "&id&"")
If Not img.EOF Then
setimg = img("photo")
End If
End Function
%>



<script type="text/javascript">

/***********************************************
* AnyLink Drop Down Menu- � Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/


//Contents for menu 7
var menu7 = new Array()
<%set objRSmenu7 = objConn.Execute ("SELECT * FROM color order by color")%>

<%
x = 1
do while not objRSmenu7.eof
%>
menu7[<%= x%>]='<a href="products.asp?action=color&amp;color=<%response.Write objRSmenu7("color")%>"><%response.Write objRSmenu7("color")%></a>'
<%
x = x + 1
objRSmenu7.movenext
loop%>



//Contents for menu 1
// Occasions
var menu1=new Array()
<%set objRSmenu1= objConn.Execute ("SELECT * FROM categories WHERE maincategid = 2")%>
<%
pp = 0
do while not objRSmenu1.eof
%>
menu1[<%= pp%>]='<a href="products.asp?Id=<%=objRSmenu1("categoryID")%>"><%
IF Instr(objRSmenu1("catdescription"), "-") <> 0 Then
namearr11 = split(Replace(objRSmenu1("catdescription"), "%20", ""), "-")
myname11 = namearr11(1)
Response.write myname11
Else
myname11 = objRSmenu1("catdescription")
Response.write myname11
End IF
%></a>'
<%
pp = pp + 1
objRSmenu1.movenext
loop%>


//Contents for menu 6
var menu6=new Array()
<%set objRSmenu6= objConn.Execute ("SELECT * FROM countries order by rank")%>
<%
x = 1
do while not objRSmenu6.eof
%>
menu6[<%= x%>]='<a href="<%=objRSmenu6("website")%>" target=_blank><%response.Write objRSmenu6("country")%></a>'
<%
x = x + 1
objRSmenu6.movenext
loop%>




//Contents for menu 4
// Themes
var menu4=new Array()
<%set objRSmenu4= objConn.Execute ("SELECT * FROM categories WHERE maincategid = 1")%>
<%
x = 0
do while not objRSmenu4.eof
%>
menu4[<%= x%>]='<a href="products.asp?Id=<%=objRSmenu4("categoryID")%>"><%
IF Instr(objRSmenu4("catdescription"), "-") <> 0 Then
namearr112 = split(Replace(objRSmenu4("catdescription"), "%20", ""), "-")
myname112 = namearr112(1)
Response.write myname112
Else
myname112 = objRSmenu4("catdescription")
Response.write myname112
End IF
%></a>'
<%
x = x + 1
objRSmenu4.movenext
loop%>



var menu2=new Array()
<%set objRSmenu2= objConn.Execute ("SELECT * FROM categories WHERE maincategid = 3")%>
<%
y = 0
do while not objRSmenu2.eof
%>
menu2[<%= y%>]='<a href="products.asp?Id=<%=objRSmenu2("categoryID")%>"><%
IF Instr(objRSmenu2("catdescription"), "-") <> 0 Then
namearr11 = split(Replace(objRSmenu2("catdescription"), "%20", ""), "-")
myname11 = namearr11(1)
Response.write myname11
Else
myname11 = objRSmenu2("catdescription")
Response.write myname11
End IF
%></a>'
<%
y = y + 1
objRSmenu2.movenext
loop%>

var menu3=new Array()
menu3[0]='<a href="products.asp?pc=1&action=price">Bestsellers under $100</a>'
menu3[1]='<a href="products.asp?pc=2&action=price">$100-$200</a>'
menu3[2]='<a href="products.asp?pc=3&action=price">$200-$300</a>'
menu3[3]='<a href="products.asp?pc=4&action=price">more than $300</a>'
//menu3[4]='<a href="products.asp?p=5&action=price">more than $200</a>'

var menuwidth='136px' //default menu width
var menubgcolor='<%=setcolor(1)%>' //menu bgcolor
var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

</script>



<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="<%=setcolor(2)%>">
<% IF Request.ServerVariables("SCRIPT_NAME") = "/index.asp" OR Request.ServerVariables("SCRIPT_NAME") = "/Index.asp" Then %>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><% set photo1 = objConn.Execute ("SELECT * FROM dynphoto WHERE photo_id = 1") %>
<% Do While Not photo1.EOF %><img src="upload2/<%=photo1("photo")%>" width="250" height="175" border="0" />
<%
photo1.MoveNext
Loop
%></td>
<td valign="top"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><% set photo9 = objConn.Execute ("SELECT * FROM dynphoto WHERE photo_id = 39") %>
<% Do While Not photo9.EOF %>
<img src="upload2/<%=photo9("photo")%>" width="100" height="50" border="0" />
<%
photo9.MoveNext
Loop
%></td>
<td><% set photo2 = objConn.Execute ("SELECT * FROM dynphoto WHERE photo_id = 2") %>
<% Do While Not photo2.EOF %>
<img src="upload2/<%=photo2("photo")%>" width="288" height="102" border="0" />
<%
photo2.MoveNext
Loop
%></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="10"></td>
</tr>
<tr>
<td align="center"><!-- BoldChat Live Chat Button HTML v1.20 (Type=Web,ChatButton=My Chat Button,ChatWindow=My Chat Window,Website=- None -,Department=- None -) -->
<table cellpadding="0" cellspacing="0" border="0">
<tr><td align="center"><a href="http://livechat.boldchat.com/aid/2229428687501697658/bc.chat?cwdid=5589275792077433795" target="_blank" onClick="window.open('http://livechat.boldchat.com/aid/2229428687501697658/bc.chat?cwdid=5589275792077433795&amp;url=' + escape(document.location.href), 'Chat6008256192087689657', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480');return false;"><img alt="Live chat by BoldChat" src="http://cbi.boldchat.com/aid/2229428687501697658/bc.cbi?cbdid=6780358222819914895" width="116" height="72" border="0" /></a></td></tr>
<tr><td align="center"><font size="1" face="Arial"><a href="http://www.boldchat.com" style="text-decoration: none"><font color="black">Live chat by </font><b><font color="#AD3100">Bold</font><font color="#003163">chat</font></b></a></font></td></tr>
</table>
<!-- /BoldChat Live Chat Button HTML v1.20 --></td>
</tr>

</table>
</td>
<td width="260" valign="top"><% set photo3 = objConn.Execute ("SELECT * FROM dynphoto WHERE photo_id = 3") %>
<% Do While Not photo3.EOF %>
<img src="upload2/<%=photo3("photo")%>" width="260" height="175" border="0" />
<%
photo3.MoveNext
Loop
%></td>
</tr>
</table>
<% END IF %>






</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" width="896"><img src="images/spacer.gif" width="1" height="6" alt="" /></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF" width="896"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" height="1"></td>
<td><a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu4, '150px')" onmouseout="delayhidemenu()"><img src="upload2/<%=setimg(57)%>" alt="" width="136" height="31" border="0" /></a></td>
<td><img src="images/spacer.gif" alt="" width="12" height="1" /></td>
<td><a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu1, '150px')" onmouseout="delayhidemenu()"><img src="upload2/<%=setimg(58)%>" alt="" width="135" height="31" border="0" /></a></td>
<td><img src="images/spacer.gif" width="12" height="1" alt="" /></td>
<td><a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu2, '150px')" onmouseout="delayhidemenu()"><img src="upload2/<%=setimg(59)%>" alt="" width="175" height="31" border="0" /></a></td>
<td><img src="images/spacer.gif" width="12" height="1" alt=""/></td>
<td><a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu3, '150px')" onmouseout="delayhidemenu()"><img src="upload2/<%=setimg(60)%>" alt="" width="109" height="31" border="0" /></a></td>
<!--<td><img src="images/spacer.gif" width="12" height="1" /></td>-->
<!--<td><a href="products.asp?action=special"><img src="images/hp1_20.gif" width="136" height="30" border="0" /></a></td>-->
<td><img src="images/spacer.gif" width="12" height="1" alt="" /></td>
<td><a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu7, '150px')" onmouseout="delayhidemenu()"><img src="upload2/<%=setimg(62)%>" alt="" width="125" height="31" border="0" /></a></td>
<td><img src="images/spacer.gif" width="12" height="1"alt="" /></td>
<td><a href="#" onclick="return clickreturnvalue()" onmouseover="dropdownmenu(this, event, menu6, '150px')" onmouseout="delayhidemenu()"><img src="upload2/<%=setimg(61)%>" alt="" width="139" height="31" border="0" /></a></td>
</tr>
</table></td>
</tr>
</table>

Will Bontrager
06-17-2012, 01:20 PM
bebelie, as circumstances require the JavaScript to be embedded on the page, try putting the JavaScript code within an HTML comment tag.


<script type="text/javascript">
<!--
/* JavaScript code */
//-->
</script>

Will

bebelie
06-17-2012, 03:22 PM
Good Day,

After putting the javascript in the html comment, the java code is not working anymore....

any other solution?

felgall
06-17-2012, 08:02 PM
bebelie, as circumstances require the JavaScript to be embedded on the page, try putting the JavaScript code within an HTML comment tag.


<script type="text/javascript">
<!--
/* JavaScript code */
//-->
</script>


The most recent browser those comments are needed for is Internet Explorer 2.

Will Bontrager
06-18-2012, 12:00 PM
Yes, understood, Stephen.

The original issue was with validation.

Will

bebelie
06-18-2012, 02:44 PM
Good Day,

Thank you.
WORKED.

but i didnt included

/*....*/
i only added

<!-- .... //-->

Will Bontrager
06-19-2012, 12:49 PM
Good Day,

Thank you.
WORKED.

but i didnt included

/*....*/
i only added

<!-- .... //-->

Yes, the /*...*/ was meant to be replaced by your own JavaScript code. Good call not including the /* and */ comment tags.

Glad it worked for you.

Will

felgall
06-19-2012, 08:12 PM
i only added

<!-- .... //-->

So how many Internet Explorer 2 visitors do you have where that will make a difference? All browsers from Netscape 2 and IE3 onward recognise the script tag and so do not need the script commented out so it doesn't display as part of the HTML.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum