User Name
Password
AppleNova Forums » Programmer's Nook »

Help me fix my validation errors.


Register Members List Calendar Search FAQ Posting Guidelines
Help me fix my validation errors.
Thread Tools
SledgeHammer
Senior Member
 
Join Date: May 2004
 
2007-04-01, 10:06

When I run my website through the W3C's HTML validator, I get 3 errors. They are all the same error, and I think I know why they are occurring, but I don't know if I can fix them.

The error is "document type does not allow element "img" here." All three instances of the error occur in the section below:
Code:
<script language="javascript" type="text/javascript"> if (navigator.appName != "Microsoft Internet Explorer") {document.write("<img src='images/homeheadtop.gif' alt='Frodos Notebook' height='126' width='630' /> <img src='images/headtail.gif' alt=' ' class='head' />")} if (navigator.appName == "Microsoft Internet Explorer") {document.write("<img src='images/iehead.gif' alt='Frodos Notebook' width='630' />")} </script>
I assume the problem comes from the tags being inside the script, but I was hoping there was a way I could keep the functionality and still get the site to validate.

The site in question.
The validator results page.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2007-04-01, 14:33

You need CDATA!

Try this:

Code:
<script language="javascript" type="text/javascript"> //<![CDATA[ if (navigator.appName != "Microsoft Internet Explorer") {document.write("<img src='images/homeheadtop.gif' alt='Frodos Notebook' height='126' width='630' /> <img src='images/headtail.gif' alt=' ' class='head' />")} if (navigator.appName == "Microsoft Internet Explorer") {document.write("<img src='images/iehead.gif' alt='Frodos Notebook' width='630' />")} //]]> </script>
  quote
SledgeHammer
Senior Member
 
Join Date: May 2004
 
2007-04-03, 13:46

That did the trick. Thanks!
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2007-04-05, 17:36

About two years ago I built something on my site that would go and scrape new stories from the pages of other sites... maybe from their feeds, can't remember. Looking back, it was pretty cool... if not more than a little wrong, though I wasn't doing any SEO stuff and gave direct links to THEIR websites... did it using CDATA somehow, for the life of me I can't remember how, now. I only learn to code for specific tasks then forget it. Repetition makes Johnny a good coder.

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2007-04-05, 18:01

CDATA simply tells parsers to ignore the contents. For example, any < or & characters in the CDATA block will not trigger the start of a tag or character entity.
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2013-11-25, 16:57

Bump. I just remembered the scraping thing again just now, and how some people at a website called "Core77" emailed me to ask how I did it. I think it was a jury-rigged version of what we now call a feed... I was copying the links and the headlines and cooking it down into a "stolen feed" from their website (so I wasn't actually stealing their content). The Core77 code person was interested in the technique.

I just felt like Forrest Gump.



...

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools
Similar Threads
Thread Thread Starter Forum Replies Last Post
Mac Pro hard drive speed fix for Windows in Boot Camp dmegatool Apple Products 1 2006-09-10 15:32
Not hearing any sound? FIX INSIDE Luca Genius Bar 0 2006-06-26 18:20
64 errors in Core D/S - come again ? m4hl3r Apple Products 23 2006-01-25 13:02
Locating Errors in Xcode 2.2 kartel9 Programmer's Nook 4 2005-11-26 18:25
SP 1.8 flaw fix Gaslight Genius Bar 8 2005-11-02 10:58


« Previous Thread | Next Thread »

All times are GMT -5. The time now is 22:28.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova