3

I have some javascript to set makers for google maps. Inside the markers I have links <a>link</a> to display on the map.

Howver the W3C valdiator complains about the > at the end of the opening <a>. I have tried replacing it with &gt; but it complained about the &.

Is there a way around this?

Thanks

["<a href='/thebrianboru'>The Brian Boru</a>&lt;br />5 Prospect R…
2
  • 1
    Did you close the <a>-Tag? And wh do you write &lt;br/> instead of <br/>? Commented May 31, 2012 at 13:35
  • yes I have the link tag closed and I had to use &lt; instead of < for the br tag as I got errors and that was the fix. Commented May 31, 2012 at 13:39

4 Answers 4

3

Seems like you're using XHTML. Wrap your code in a commented out CDATA:

<script type="text/javascript">
//<![CDATA[

// Now I won't complain :)
var x = '<7>%></a>#$#><>><&&>';

//]]>
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

Sounds like XHTML? Put the JavaScript in a CDATA section: http://en.wikipedia.org/wiki/CDATA to tell the interpreter, that it should ignore special characters like < > and &.

<script>
<![CDATA[
    // ...
]]>
</script>

Comments

0

If this is inside of a <script></script> block in HTML, it could cause problems:

The script should not contain the sequence

</ because it could be confused with the </script>. Inserting a backslash between < and / in strings avoids the problem.

<\/

http://javascript.crockford.com/script.html

Comments

0

You can use any of them below:

<script type="text/javascript">
<!--
YOUR JS CODE .........
alert("www.mykitchenroom.com");
// -->
</script>

OR,

<script type="text/javascript">
//<![CDATA[
YOUR JS CODE .........
alert("www.scienceanddevelops.com");
//]]>
</script>

W3C will don't check your code.

Thanks And Regards, Subhojit Mukherjee

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.