Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escape character will not XHTML validate!

Status
Not open for further replies.

JamesManke

Programmer
Jul 1, 2004
54
CA
When using the code below internally on my page (which I must do because I am using ColdFusion variables), the page will not XHTML validate because of the escape "\". Is there a way around this?

Example:
<script language="JavaScript" type="text/javascript">
document.write("&nbsp;<a class=\"preview\" onmouseup=\"changeColor('#show_all.name#')\" onclick=\"document.main.src=details_#image_counter#.src\" href=\"javascript:;\" onfocus=\"blur()\">#show_all.name#</a>&nbsp;");
</script>

When validating I get the error,

Error: an attribute value must be quoted if it contains any character other than letters (A-Za-z), digits, hyphens, and periods; use quotes if in doubt

Thanks for your help,
James
 

Yes. Change all occurrences of this:

Code:
\"

to this:

Code:
\&quot;

Just because you are document.writing the HTML instead of putting it directly on the page doesn't mean you should avoid escaping your code.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 

You'd need to escape the values of the server-side content that is being delivered to the page. The line as you have it right there validates as strict XHTML 1.1

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top