1 reply [Last post]
gerard
Offline
Regular
Last seen: 14 years 35 weeks ago
Joined: 2005-08-19
Posts: 45
Points: 0

Hi

I got some javascript code to use as a 'bookmark this page' link, but it's serving to invalidate my page:

http://www.wefwayconsulting.com/site/index.php

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.wefwayconsulting.com%2Fsite%2Findex.php

This is the guilty code:

function bookmarksite(title,url){
if (window.sidebar) // firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all)// ie
window.external.AddFavorite(url, title);
}

...specifically the double ampersand in:

(window.opera && window.print)

Is there any easy fix for this? Or maybe some different code that does validate?

Many thanks

Gerard

Tags:
Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 38 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Hide your script then

Hide your script then between cdata sections

It's more a problem with the validator and the fact it has to think this is proper XHTML

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me