By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,767 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,767 IT Pros & Developers. It's quick & easy.

Validator doesnt like my javascript can some help me?

P: n/a
Hey everyone,

I have this browser detect script and the validator is having problems with
it, im trying to validate a page for XHTML 1.0 Transitional

If you have any ideas or suggestions they would be greatly appericated
Here is the script and the error that validtor spits out

<script language="JavaScript" type="text/javascript">
function button()
{
if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {
document.write('<input type="button" onclick="ClipBoard();" value="Copy"
/>');
} else {
document.write("");
}
}
</script>

1.. Line 14, column 55: character "&" is the first character of a
delimiter but occurred as data

...pName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {

If you wish to include the "<" character in your output, you should escape
it as "&lt;". Another possibility is that you forgot to close quotes in a
previous tag.

2.. Line 14, column 56: character "&" is the first character of a
delimiter but occurred as data

if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {

3.. Line 15, column 75: document type does not allow element "input" here

...ton" onclick="ClipBoard();" value="Copy" />');

The element named above was found in a context where it is not allowed.
This could mean that you have incorrectly nested elements -- such as a
"style" element in the "body" section instead of inside "head" -- or two
elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML
documents. Due to HTML's rules of implicitly closed elements, this error can
create cascading effects. For instance, using XHTML's "self-closing" tags
for "meta" and "link" in the "head" section of a HTML document may cause the
parser to infer the end of the "head" section and the beginning of the
"body" section (where "link" and "meta" are not allowed; hence the reported
error).
Jul 20 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
Sheperd wrote:
I have this browser detect script and the validator is having problems
with it, im trying to validate a page for XHTML 1.0 Transitional


http://www.w3.org/TR/xhtml1/#h-4.8
http://www.hixie.ch/advocacy/xhtml

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 20 '05 #2

P: n/a
Sheperd wrote:
I have this browser detect script and


Why are you trying to detect the browser?

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #3

P: n/a
Sheperd wrote:
Hey everyone,

I have this browser detect script and the validator is having problems with
it, im trying to validate a page for XHTML 1.0 Transitional

If you have any ideas or suggestions they would be greatly appericated
Here is the script and the error that validtor spits out

<script language="JavaScript" type="text/javascript">
function button()
{
if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {
document.write('<input type="button" onclick="ClipBoard();" value="Copy"
/>');
} else {
document.write("");
}
}
</script>

1.. Line 14, column 55: character "&" is the first character of a
delimiter but occurred as data

...pName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {

If you wish to include the "<" character in your output, you should escape
it as "&lt;". Another possibility is that you forgot to close quotes in a
previous tag.

2.. Line 14, column 56: character "&" is the first character of a
delimiter but occurred as data

if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {

3.. Line 15, column 75: document type does not allow element "input" here

...ton" onclick="ClipBoard();" value="Copy" />');

The element named above was found in a context where it is not allowed.
This could mean that you have incorrectly nested elements -- such as a
"style" element in the "body" section instead of inside "head" -- or two
elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML
documents. Due to HTML's rules of implicitly closed elements, this error can
create cascading effects. For instance, using XHTML's "self-closing" tags
for "meta" and "link" in the "head" section of a HTML document may cause the
parser to infer the end of the "head" section and the beginning of the
"body" section (where "link" and "meta" are not allowed; hence the reported
error).


You're not alone.

Their *HTML validator hates Yahoo's Geocities javascript Ad Boxes, too.
My HTML is valid 4.01 Transitional, but Yahoo's ads generate 21 errors
on my home page!
Jul 20 '05 #4

P: n/a

Sheperd wrote:
Hey everyone,

I have this browser detect script and the validator is having problems with
it, im trying to validate a page for XHTML 1.0 Transitional

If you have any ideas or suggestions they would be greatly appericated
Here is the script and the error that validtor spits out

<script language="JavaScript" type="text/javascript">
function button()
{
if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {
document.write('<input type="button" onclick="ClipBoard();" value="Copy"
/>');
} else {
document.write("");
}
}
</script>


Change the < and > to &lt; and &gt; in the "input" string, like this:

('&lt;input type="button" onclick="ClipBoard();" value="Copy"/&gt;')

I belive that solve all errors

--
/Arne
Jul 20 '05 #5

P: n/a
Hey Arne

That worked perfectly thank you very much

The reason I have it detect different browsers is because I have a script
that copies text to the clip board but it only works for IE and so the
detect doest create the copy button

Thanks to all who responded to my cry help

Sheperd

"Arne" <ar********@telia.com> wrote in message
news:YW******************@newsb.telia.net...

Sheperd wrote:
Hey everyone,

I have this browser detect script and the validator is having problems with it, im trying to validate a page for XHTML 1.0 Transitional

If you have any ideas or suggestions they would be greatly appericated
Here is the script and the error that validtor spits out

<script language="JavaScript" type="text/javascript">
function button()
{
if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {
document.write('<input type="button" onclick="ClipBoard();" value="Copy" />');
} else {
document.write("");
}
}
</script>


Change the < and > to &lt; and &gt; in the "input" string, like this:

('&lt;input type="button" onclick="ClipBoard();" value="Copy"/&gt;')

I belive that solve all errors

--
/Arne

Jul 20 '05 #6

P: n/a
DU
Sheperd wrote:
Hey everyone,

I have this browser detect script and the validator is having problems with
it, im trying to validate a page for XHTML 1.0 Transitional

If you have any ideas or suggestions they would be greatly appericated
Here is the script and the error that validtor spits out

<script language="JavaScript" type="text/javascript">
language is deprecated; I recommend you just use type instead.

Here, you need to escape the code

http://www.w3.org/TR/2002/REC-xhtml1-20020801/#h-4.8

like this:

<script type="text/javascript">
// <![CDATA[
function button()
{
....
}
// ]]>
</script>

so that &, <, >, \ are not interpreted as markup

function button()
I recommend you choose another name for that function, a more
descriptive name; this helps reviewing your code by others and helps
your own understanding of your functions script.
{
if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {
document.write('<input type="button" onclick="ClipBoard();" value="Copy"
/>');
This is definately not the best way to detect a browser. You should use
object support detection for whatever your real webpage design needs are.

http://jibbering.com/faq/#FAQ4_26

DU
} else {
document.write("");
}
}
</script>

1.. Line 14, column 55: character "&" is the first character of a
delimiter but occurred as data

...pName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {

If you wish to include the "<" character in your output, you should escape
it as "&lt;". Another possibility is that you forgot to close quotes in a
previous tag.

2.. Line 14, column 56: character "&" is the first character of a
delimiter but occurred as data

if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {

3.. Line 15, column 75: document type does not allow element "input" here

...ton" onclick="ClipBoard();" value="Copy" />');

The element named above was found in a context where it is not allowed.
This could mean that you have incorrectly nested elements -- such as a
"style" element in the "body" section instead of inside "head" -- or two
elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML
documents. Due to HTML's rules of implicitly closed elements, this error can
create cascading effects. For instance, using XHTML's "self-closing" tags
for "meta" and "link" in the "head" section of a HTML document may cause the
parser to infer the end of the "head" section and the beginning of the
"body" section (where "link" and "meta" are not allowed; hence the reported
error).

Jul 20 '05 #7

P: n/a
Sheperd wrote:
That worked perfectly thank you very much
First, please don't top-post.
The reason I have it detect different browsers is because I have a
script that copies text to the clip board but it only works for IE
Then the solution is to make it work on the www, instead of in one
operating system component that pretends (sort of) to be a browser.
and so the detect doest create the copy button


Not hardly. What happens when someone fakes the ua string -- all too
common, often to defeat clueless browser sniffing.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #8

P: n/a
DU
Sheperd wrote:
Hey Arne

That worked perfectly thank you very much

The reason I have it detect different browsers is because I have a script
that copies text to the clip board
Then you should do a browser detect based on its support for the
particular property involved within your webpage design needs. It's not
only much more reliable but it's also more sensible script design.
Spoofed appName is very common with alternative browsers.

if(self.clipboardData) {button display on} else {button display off}.
should work in MSIE 5+. Your code assumes that clipboard data is
available in MSIE 4 but that's not true.

DU
but it only works for IE and so the detect doest create the copy button

Thanks to all who responded to my cry help

Sheperd

"Arne" <ar********@telia.com> wrote in message
news:YW******************@newsb.telia.net...
Sheperd wrote:

Hey everyone,

I have this browser detect script and the validator is having problems
with
it, im trying to validate a page for XHTML 1.0 Transitional

If you have any ideas or suggestions they would be greatly appericated
Here is the script and the error that validtor spits out

<script language="JavaScript" type="text/javascript">
function button()
{
if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4) ) {
document.write('<input type="button" onclick="ClipBoard();"
value="Copy"
/>');
} else {
document.write("");
}
}
</script>

Change the < and > to &lt; and &gt; in the "input" string, like this:

('&lt;input type="button" onclick="ClipBoard();" value="Copy"/&gt;')

I belive that solve all errors

--
/Arne


Jul 20 '05 #9

P: n/a
On Mon, 26 Jul 2004 18:49:04 -0400, Brian
<us*****@julietremblay.com.invalid> wrote:
Sheperd wrote:
That worked perfectly thank you very much


First, please don't top-post.
The reason I have it detect different browsers is because I have a
script that copies text to the clip board but it only works for IE


Then the solution is to make it work on the www, instead of in one
operating system component that pretends (sort of) to be a browser.


In theory, this is a situation where something unessential is added as an
optional feature. I don't see a problem if you're doing something just in
IE, so long as page functionality is maintained on all UAs.
and so the detect doest create the copy button


Not hardly. What happens when someone fakes the ua string -- all too
common, often to defeat clueless browser sniffing.


Right. That's the real problem here. Many browsers which are not IE will
dress up as IE for the server - and they get the button, and it won't
work. Choose a method which is not susceptible to that fakeout.
Jul 20 '05 #10

P: n/a
Neal wrote:
Brian wrote:
Sheperd wrote:
The reason I have it detect different browsers is because I
have a script that copies text to the clip board but it only
works for IE


Then the solution is to make it work on the www, instead of in
one operating system component


In theory, this is a situation where something unessential is added
as an optional feature. I don't see a problem if you're doing
something just in IE, so long as page functionality is maintained
on all UAs.


Fair enough. But I'd prefer that authors make sure that the feature is
only available in IE/Win before coding it that way. The blinders that
many authors wear prevent them from seeing Mozilla, Opera, Safari, et. al.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #11

P: n/a
Sheperd wrote:
<snip>
..., im trying to validate a page for XHTML 1.0
Transitional <snip> <script language="JavaScript" type="text/javascript">
function button()
{
if ((navigator.appName=="Microsoft Internet
Explorer")&&(parseInt(navigator.appVersion)>=4)) {
document.write('<input type="button" onclick="ClipBoard();"
value="Copy" />');
} else {
document.write("");
}
}
</script>

<snip>

Currently no scriptable XHTML DOM implementations support -
document.wirte - operations. If you are relying on a browser providing a
scriptable HTML DOM it makes more sense to be writing HTML documents.

Richard.

Jul 20 '05 #12

P: n/a
Brian <us*****@julietremblay.com.invalid> wrote:
Fair enough. But I'd prefer that authors make sure that the feature is
only available in IE/Win before coding it that way. The blinders that
many authors wear prevent them from seeing Mozilla, Opera, Safari, et. al.


Well, in this particular case (copying content to the clipboard), I think
the best bet would be to drop the "feature" completely. Anyone who knows
how to use the clipboard can copy exactly what they want to the clipboard
without the button, and they're likely to do it the normal way anyway,
rather than using the button.
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

key ring /'kE 'ri[ng]/ n. device enabling simultaneous loss of multiple keys
Jul 20 '05 #13

P: n/a
Darin McGrew wrote:
Brian wrote:
I'd prefer that authors make sure that the feature is only
available in IE/Win before coding it that way.


Well, in this particular case (copying content to the clipboard), I
think the best bet would be to drop the "feature" completely.
Anyone who knows how to use the clipboard can copy exactly what
they want to the clipboard without the button


Come to think of it, this seems like much more useful advice. Anytime
you find yourself redesigning a built-in browser/os feature in
JavaScript, it's time to step back and rethink things. The time is
better spent on creating new content.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.