hralston Posted August 7, 2012 Report Share Posted August 7, 2012 I have a script that will work fine in Firefox but not Chrome, Opera, Microsoft Explorer.The console has this in Chrome-uncaught syntax error: Unexpected token < It is in the page-http://www.ralstongenealogy.com/visitor.htm This is the script- /* <![CDATA[*/document.writeln(<div id="page-footer"> <a href="#top"><img src="uparrow.gif" alt="To top of page" /></a> <a href="index.htm"><img src= "homarrow.gif" border="1" width="72" height="28" alt="To Home Page" /></a> © 2012 Harold A. Ralston, Racine, Wisconsin, USA.<br /> Design and material may be copied with web page author's permission. <a href="visitor.htm"><img src="letter.gif" alt="e-mail" width="35" height="24" />E Mail</a> <a href="http://www.chami.com/html-kit/"><img src= "hkbutton.gif" width="93" height="30" alt="HTML-Kit Button" title="Built using HTML-Kit" border="0" /></a></div> ); dayName=new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") monName =new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") now=new Date document.write ( dayName[now.getDay()] +", "+monName[now.getMonth()] + " "+now.getDate()+", "+now.getFullYear()+". <br>" ); /*]]> */ Link to comment Share on other sites More sharing options...
justsomeguy Posted August 7, 2012 Report Share Posted August 7, 2012 It's not necessary to have the cdata comments there, but that's not going to break anything. The document.writeln method takes a string as an argument, which means it needs to be quoted. You can use either single quotes or double quotes to quote a string, so since you're already using a lot of double quotes it's probably easier to surround the string with single quotes. You also need to add a "\" character at the end of each line inside the string. e.g.: document.writeln('<div id="page-footer">\ <a href="#top"><img src="uparrow.gif"\...'); The error message is complaining about the first "<" in the HTML markup that isn't quoted. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now