[Javascript] How to get valid XHTML when links contain "invalid characters"
Jonathan Gold
johnnyclock at gmail.com
Tue Jan 31 21:48:42 CST 2006
I find another thing you can do is wrap the javascript anchor links as
CDATA sections, thus:
// <![CDATA[
<a href="javascript:viewMapWin('http://www.mapquest.com/maps/map.adp?formtype=address&searchtype=address&country=US&addtohistory=&address=400+East+Church+Street&city=Frederick&state=MD&zipcode=21701')">view
a map</a>
//]]>
Sorry about the length of that line. Anyhow, the links still work (I'm
in FF 1.5) and the W3C Validator passes it.
On 1/31/06, Roger Roelofs <rer at datacompusa.com> wrote:
> Janie,
>
> On Jan 31, 2006, at 10:12 PM, Janie Hadsel wrote:
>
> > This may be OT, but I've been trying to get a page with links to
> > Mapquest URLs to validate according to the W3C. Since they are
> > external links I've used Javascript to open them in new windows, and I
> > was surprised to find that the W3C validator still viewed them as
> > XHTML when they were passed to a Javascript function. Any ideas?
> >
> > Here's the link: http://www.gimv.org/contact/locations.htm
>
> the & is a special character. To validate replace then with &
> Also, it would be better to write the a element like this...
>
> <a
> href="http://www.mapquest.com/maps/map.adp?formtype=address&
> searchtype=address&country=US&addtohistory=&
> address=400+East+Church+Street&city=Frederick&state=MD&
> zipcode=21701" class="maplink">view a map</a>
>
> See <http://adactio.com/atmedia2005/> for a good example.
>
> // add this to the script in the head section
> function doMapLinks() {
> if (!document.getElementsByTagName) return false;
> var links = document.getElementsByTagName("a");
> for (var i=0; i < links.length; i++) {
> if (links[i].className.match("maplink")) {
> links[i].onclick = function() {
> viewMapWin(this.href);
> return false;
> }
> }
> }
> }
> window.onload = doMapLinks;
>
> --
> Roger Roelofs
> Datacomp Appraisal Services
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
--
Jonathan
Berkeley, CA
http://home.pacbell.net/jonnygee/
More information about the Javascript
mailing list