Forum Moderators: open

Message Too Old, No Replies

Javascript and W3C

How to get rid of one error

         

tomda

1:19 pm on May 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I get the following error when validating my page
end tag for element "A" which is not open

But when looking at the script, the a tag is open (IEstring)?

<script type='text/javascript'>
<!--
var IEstring = "<a href='javascript:window.external.addFavorite(location.href,document.title);' title='Add to Favorites'><img src='http://localhost/beta.#*$!xx.com/images/favorites.gif' width='13' height='11' alt='Add to My favorites' title='Add to My favorites'></a>" ;
var NSstring = "<img src='http://localhost/beta.xxxxx.com/images/favorites.gif' width='13' height='11' alt='Add to My favorites' title='Add to My favorites'> Type [Ctrl+D]";
var OPstring = "<img src='http://localhost/beta.xxxxx.com/images/favorites.gif' width='13' height='11' alt='Add to My favorites' title='Add to My favorites'> Type [Ctrl+T]";
var OTHstring = "<img src='http://localhost/beta.xxxxxx.com/images/favorites.gif' width='13' height='11' alt='Add to My favorites' title='Add to My favorites'> Bookmark me!"
var whichString = OTHstring ;
var agt = navigator.userAgent.toLowerCase();
var app = navigator.appName.toLowerCase();
var ieAgent = agt.indexOf('msie');
var nsAgent = app.indexOf('netscape');
var opAgent = app.indexOf('opera');
if (ieAgent!= -1) { whichString = IEstring; } else if (nsAgent!= -1){ whichString = NSstring; } else if (opAgent!= -1){whichString = OPstring;}
document.write(whichString)
//-->
</SCRIPT>

Thank you

Bernard Marx

1:26 pm on May 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What are you validating as?
Try:

1) Swapping single quotes for double, and vice-versa.
doc.write('<a attribute="value">')

2) Escape forward slashes in the text strings.
'<\/a>'

tomda

7:47 am on May 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, sorry!
I am validating as HTML 4.0 Transitional.

The second option did the work.
Thanks Bernard