Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   W3C html validator flags error in javascript (http://www.velocityreviews.com/forums/t164623-w3c-html-validator-flags-error-in-javascript.html)

xyZed 03-25-2006 01:24 PM

W3C html validator flags error in javascript
 
Although related to false javascript errors during validation checks,
this is a question about html validation.

I have several affiliate links stopping my pages validating. They use
javascript which I don't understand. Apparently it's a known issue
that html validators can erroneously flag javascript errors.

I have read the information on this page

http://www.htmlhelp.com/tools/valida...ms.html#script

which offers a solution. But I do not want to accidently disable the
javascript functions of my affiliate links by adding stuff I don't
understand.

The W3C (and dreamweaver's) validators flag the following error -

< found between tags. Consider using the equivalent entity (&amp =
'&', &lt = '<', &gt = '>', &quot = quotation mark). [HTML 4.0]

And this is the script it flags up -

<script type="text/javascript">
var uri = 'http://impgb.tradedoubler.com/imp/js/16125532/1079419?' +
new String (Math.random()).substring (2, 11);
document.write('<sc'+'ript language="javaScript" src="'+uri+'"
charset="ISO-8859-1"></sc'+'ript>');
</script>


I can fix this by adding a back slash here <\/sc'+'ript>' as mentioned
on
http://www.htmlhelp.com/tools/validator/problems.html#script

<quoting relevant passage>

"A common error (and the most common source of erroneous bug reports
for the WDG HTML Validator) occurs when writing HTML tags within a
SCRIPT element:

<script type="text/javascript">
<!--
// This is an error!
document.write("</P>");
// -->
</script>

(The fix is to add a backslash -)

<script type="text/javascript">
<!--
document.write("<\/P>");
// -->
</script>
</quote>


I'm hoping someone can tell me if this is a legitimate fix and that it
won't interfere with the javascript functions please












--

Free washing machine help and advice.

www.washerhelp.co.uk

www.xyzed.co.uk/newsgroups/top-posting.html

Jukka K. Korpela 03-25-2006 02:06 PM

Re: W3C html validator flags error in javascript
 
xyZed wrote:

> Although related to false javascript errors during validation checks,
> this is a question about html validation.


It's about validation of HTML documents, but it's not about "false
javascript errors", just about common failures to understand what
validation is.

> I have several affiliate links stopping my pages validating. They use
> javascript which I don't understand.


Too bad. Your choice: get rid of them or learn to understand what this
is about, then perhaps fix them.

> Apparently it's a known issue
> that html validators can erroneously flag javascript errors.


It's not true at all.

> I have read the information on this page
> http://www.htmlhelp.com/tools/valida...ms.html#script
>
> which offers a solution.


Indeed. Another solution is to put JavaScript code into an external
file. Yet another, often feasible and perhaps the best, is to remove the
JavaScript code or to replace it by something more robust (like
replacing a fake "JavaScript link" by a real link).

> The W3C (and dreamweaver's) validators flag the following error -
>
> < found between tags. Consider using the equivalent entity (&amp =
> '&', &lt = '<', &gt = '>', &quot = quotation mark). [HTML 4.0]


What are you referring to? Please specify the source of your quotations.

> And this is the script it flags up -
>
> <script type="text/javascript">
> var uri = 'http://impgb.tradedoubler.com/imp/js/16125532/1079419?' +
> new String (Math.random()).substring (2, 11);
> document.write('<sc'+'ript language="javaScript" src="'+uri+'"
> charset="ISO-8859-1"></sc'+'ript>');
> </script>


The _error_ here, assuming HTML 4 rules, is the presence of "</sc",
which starts an end tag. There is no such tag in HTML 4 and, besides, no
end tags are allowed within a <script> element. This has _nothing_ to do
with flagging JavaScript errors or processing JavaScript in any way.

> I can fix this by adding a back slash here <\/sc'+'ript>' as mentioned
> on
> http://www.htmlhelp.com/tools/validator/problems.html#script


Yes, or by using an external file. Or by other means, but these two are
the simplest, probably.

> I'm hoping someone can tell me if this is a legitimate fix and that it
> won't interfere with the javascript functions please


Huh? Do you expect the general level of expertise in this group to
exceed that of the people beging the www.htmlhelp.com site? Rest assured
it doesn't. But you can also check the _official_ (though sloppily
written) HTML 4 specification and see that the same method is suggested
there, though this has been hidden into an appendix:
http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2

Toby Inkster 03-25-2006 02:54 PM

Re: W3C html validator flags error in javascript
 
xyZed wrote:

> I have several affiliate links stopping my pages validating. They use
> javascript which I don't understand. Apparently it's a known issue
> that html validators can erroneously flag javascript errors.


Firstly, the validator is not erroneous -- it is acting correctly -- your
HTML is invalid.

Secondly, there is no Javascript error. The Javascript is fine in itself;
it has simply been embedded into the HTML wrongly.

> I have read the information on this page
> http://www.htmlhelp.com/tools/valida...ms.html#script
> which offers a solution. But I do not want to accidently disable the
> javascript functions of my affiliate links by adding stuff I don't
> understand.


The solution proposed on that page is fine. It won't change how your
Javascript operates.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact


xyZed 03-27-2006 04:50 PM

Re: W3C html validator flags error in javascript
 
There is circumstantial evidence that on Sat, 25 Mar 2006 16:06:58
+0200, "Jukka K. Korpela" <jkorpela@cs.tut.fi> wrote
__________________________________________________ _____


> > I have several affiliate links stopping my pages validating. They use
> > javascript which I don't understand.
>
> Too bad. Your choice: get rid of them or learn to understand what this
> is about, then perhaps fix them.


Exactly why I posted. This is my first step.

> > Apparently it's a known issue
> > that html validators can erroneously flag javascript errors.
>
> It's not true at all.


They flag phantom html errors, not (as I said) javascript errors,
and of course it's not the fault of the html validators.


> ... Another solution is to put JavaScript code into an external
> file.


That may be a good idea, would it have advantages other than the one
discussed here I wonder? I'd have to look into how it would work for
affiliate links and banners that are different on each page though.

> ..Yet another, often feasible and perhaps the best, is to remove the
> JavaScript code or to replace it by something more robust (like
> replacing a fake "JavaScript link" by a real link).


I have yet to learn about doing such things. I hate having to use
other people's rubbish code. It seems to me that the overwhelming
majority of affiliate link code is poorly coded javascript. You are
right that I should learn what code is being put on my site but I am
so busy running and updating my site I have not had time. I do need
the affiliate links though so it's something I've seen as a necessary
evil.

Thanks for the links


--

Free washing machine help and advice.

www.washerhelp.co.uk

www.xyzed.co.uk/newsgroups/top-posting.html

xyZed 03-27-2006 04:54 PM

Re: W3C html validator flags error in javascript
 
There is circumstantial evidence that on Sat, 25 Mar 2006 14:54:02
+0000, Toby Inkster <usenet200603@tobyinkster.co.uk> wrote
__________________________________________________ _____


> Firstly, the validator is not erroneous -- it is acting correctly -- your
> HTML is invalid.


> Secondly, there is no Javascript error. The Javascript is fine in itself;
> it has simply been embedded into the HTML wrongly.


The validator is flagging erroneous errors, but only because the
poorly written javascript code fools the html validator into thinking
the code is html (or something like that) I think I mistakenly said
they were flagging javascript errors but the correct observation
should be they are flagging html errors in javascript code?


> > I have read the information on this page
> > http://www.htmlhelp.com/tools/valida...ms.html#script
> > which offers a solution. But I do not want to accidently disable the
> > javascript functions of my affiliate links by adding stuff I don't
> > understand.
>
> The solution proposed on that page is fine. It won't change how your
> Javascript operates.


Thank you.

--

Free washing machine help and advice.

www.washerhelp.co.uk

www.xyzed.co.uk/newsgroups/top-posting.html


All times are GMT. The time now is 09:30 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.