473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Validator doesnt like my javascript can some help me?

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
13 1974
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
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
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

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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Colin Cogle | last post by:
------- Line 47, column 8: there is no attribute "id" <DIV id="LeftNavigation" style="position:absolute; left:8px; top:6px; width:200p ------- Line 47, column 31: there is no attribute "style"...
0
by: Heinz Kleinbauer | last post by:
Hello I have a Java Application with a CSS Validator in it (http://jigsaw.w3.org/css-validator/). Now I should modify certain properties but i dont know exactly how i have to do this. I have to...
2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
4
by: moondaddy | last post by:
Is there a asp.net validator control that validates the length of the text being entered or does everyone just write jscript for this? -- moondaddy@nospam.com
2
by: Dot net work | last post by:
Hello. Say I have a .net textbox that uses a .net regularexpressionvalidator. If the regular expression fails, is it possible to launch a small client side javascript function to do something,...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
1
by: MattB | last post by:
I have a page with dual controls for a person to enter their height and weight. The dual controls are for English and metric units, and Javascript onChange events handle populating the other...
43
by: SLH | last post by:
hi people. im trying to validate input received via a text area on an ASP page before writing it to a database. i cant use client side javascript due to policy, so it all has to happen on the...
0
by: Dhanashree | last post by:
I have a RangeValidator which uses AJAX to call server-side validation function from the client. The code works fine, but I have one problem. following is my range validator class: public...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.