Senior Member
Join Date: May 2004
|
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 |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
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 |
Senior Member
Join Date: May 2004
|
That did the trick. Thanks!
|
quote |
Space Pirate
Join Date: May 2004
Location: Atlanta
|
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.
|
quote |
Selfish Heathen
Join Date: May 2004
Location: Zone of Pain
|
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 |
Space Pirate
Join Date: May 2004
Location: Atlanta
|
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. ... |
quote |
Posting Rules | Navigation |
|
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 |