Reply LinkBack Thread Tools Search this Thread
Old 06-07-2004, 08:36   #1 (permalink)
blazedesigns
Senior Member
 
blazedesigns's Avatar
 
Join Date: Mar 2004
Location: Somewhere you can't find me
Posts: 101
Javascript, CSS and XHTML Compatability Help

I'm currently creating a page and I want it to go by coding stardards so how do I make the following code Valid XHTML 1.0 Transitional?

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Documentation Audit</title>
<meta http-equiv="Content-Type" content="text/xml; charset=iso-8859-1" />
<link href="allstyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!-- Begin
var NS4 = (document.layers);
var IE4 = (document.all);

var win = this;
var n = 0;

function findInPage(str) {
var txt, i, found;
if (str == "")
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0) alert(str + " was not found on this page.");
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert(str + " was not found on this page.");
}
}
return false;
}
// End -->
</script>
</head>

I've tried all I can but can't figure it out. Would be grateful for any help.
__________________
To recover from my internet addiction I will eat breakfast with a knife and fork and not with one hand typing.
  Reply With Quote
Old 06-07-2004, 08:38   #2 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,625
It's javascript.
  Reply With Quote
Old 06-07-2004, 08:41   #3 (permalink)
blazedesigns
Senior Member
 
blazedesigns's Avatar
 
Join Date: Mar 2004
Location: Somewhere you can't find me
Posts: 101
Quote:
Originally Posted by Stickman
It's javascript.

Yeh but how do u make it so its compatable with XHTML 1.0. (Making it so it follows coding standards)

Or is it just impossible?
__________________
To recover from my internet addiction I will eat breakfast with a knife and fork and not with one hand typing.
  Reply With Quote
Old 06-07-2004, 09:01   #4 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,625
How well a bit of javascript adheres to standards depends on what it does. Can people use your site without it?

Anyway, just link to it:
Quote:
<script type="text/javascript" src="yourscript.js"></script>
  Reply With Quote
Old 06-07-2004, 09:03   #5 (permalink)
cam
vague™
 
cam's Avatar
 
Join Date: Mar 2004
Location: Glasgow
Posts: 5,126
adding

<body>
</body>
</html>

and firing it through the w3c validator brings up "This Page Is Valid XHTML 1.0 Transitional!"

...
__________________
Random goodness at The Blog

  Reply With Quote
Old 06-07-2004, 09:12   #6 (permalink)
blazedesigns
Senior Member
 
blazedesigns's Avatar
 
Join Date: Mar 2004
Location: Somewhere you can't find me
Posts: 101
Quote:
Originally Posted by Stickman
How well a bit of javascript adheres to standards depends on what it does. Can people use your site without it?

Anyway, just link to it:

I'll try that

No, people cant use the site without it. I've designed it for an intranet and its an audit of all the businesses files. There plenty of them. So the site search helps them quickly find the document they are look for.
__________________
To recover from my internet addiction I will eat breakfast with a knife and fork and not with one hand typing.
  Reply With Quote
Old 06-07-2004, 09:12   #7 (permalink)
dan
Iris Folder
 
dan's Avatar
 
Join Date: Apr 2003
Location: smokey
Posts: 2,672
Is this where the CDATA thing comes in ?

but stick's idea always seems cleaner.
  Reply With Quote
Old 06-07-2004, 09:18   #8 (permalink)
erilidon
teh sUxX0r
 
Join Date: Jun 2004
Posts: 43
Quote:
Originally Posted by blazedesigns
I'll try that

you shouldn't have any problem with it if you link to it, thats how I get all my pages to validate
  Reply With Quote
Old 06-07-2004, 09:30   #9 (permalink)
blazedesigns
Senior Member
 
blazedesigns's Avatar
 
Join Date: Mar 2004
Location: Somewhere you can't find me
Posts: 101
Quote:
Originally Posted by erilidon
you shouldn't have any problem with it if you link to it, thats how I get all my pages to validate

You'd be wrong. It still didnt validate. Without the Javascript it validates nicely. But with it it just gets... urgh!
__________________
To recover from my internet addiction I will eat breakfast with a knife and fork and not with one hand typing.
  Reply With Quote
Old 06-07-2004, 09:35   #10 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,875
Quote:
Originally Posted by Stickman
How well a bit of javascript adheres to standards depends on what it does. Can people use your site without it?
Don't go forgetting the W3C DOM.
There's more to implementing standards-compliant javascript than simply considering whether or not a page remains accessible without it.



A good source of info for you, blazedesign:
http://www.w3.org/DOM/faq.html
http://www.mozilla.org/docs/dom/domref/
http://www.mozilla.org/docs/dom/domr...ro.html#997525
http://www.quirksmode.org/

-

Do you have an online example which we can view for ourselves?
We will also be able to see what error the validator is throwing up.

As erilidon says, using an external js file should bypass any problems with js in your markup causing it to invalidate the page.
  Reply With Quote
Old 06-07-2004, 09:39   #11 (permalink)
blazedesigns
Senior Member
 
blazedesigns's Avatar
 
Join Date: Mar 2004
Location: Somewhere you can't find me
Posts: 101
Quote:
Originally Posted by Bill Posters
Do you have an online example which we can view for ourselves?
We will also be able to see what error the validator is throwing up.

I'll see what I can do. It's just the information it shows is confidential so I can't upload all of the document. Bare with me....
__________________
To recover from my internet addiction I will eat breakfast with a knife and fork and not with one hand typing.
  Reply With Quote
Old 06-07-2004, 09:41   #12 (permalink)
erilidon
teh sUxX0r
 
Join Date: Jun 2004
Posts: 43
Quote:
Originally Posted by blazedesigns
You'd be wrong. It still didnt validate. Without the Javascript it validates nicely. But with it it just gets... urgh!

how interestingly peculiar.. I used that code up there and linked to it then checked it with a xhtml valuator.. and there were no errors.

do you have an online example?

did you use the right format..
<script type="text/javascript" src="./blah.js"></script>
  Reply With Quote
Old 06-07-2004, 09:43   #13 (permalink)
blazedesigns
Senior Member
 
blazedesigns's Avatar
 
Join Date: Mar 2004
Location: Somewhere you can't find me
Posts: 101
Here's the results.

When I take the Javascript out none of the errors are shown.
Attached Files
File Type: zip Validation Results.zip (10.0 KB, 60 views)
__________________
To recover from my internet addiction I will eat breakfast with a knife and fork and not with one hand typing.
  Reply With Quote
Old 06-07-2004, 09:50   #14 (permalink)
erilidon
teh sUxX0r
 
Join Date: Jun 2004
Posts: 43
Quote:
Originally Posted by blazedesigns
Here's the results.

When I take the Javascript out none of the errors are shown.

do you know CSS? I'm not sure.. but I think thats the only way to fix that. also watch your captilization
  Reply With Quote
Old 06-07-2004, 09:57   #15 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
Everything needs to be in lower case onSubmit == onsubmit etc...

You also need to double quote your values. size=15 == size="15"

try that for now.
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 06-07-2004, 10:01   #16 (permalink)
blazedesigns
Senior Member
 
blazedesigns's Avatar
 
Join Date: Mar 2004
Location: Somewhere you can't find me
Posts: 101
Quote:
Originally Posted by erilidon
do you know CSS? I'm not sure.. but I think thats the only way to fix that. also watch your captilization

Yeh I know CSS. But I dont see how that would help as the css s fine with the document. Its when the javascript is placed in that all the errors occur. I validated it before I put th javascript in and it was fine. But once it was in it created a whole load of other errors.
__________________
To recover from my internet addiction I will eat breakfast with a knife and fork and not with one hand typing.
  Reply With Quote
Old 06-07-2004, 10:05   #17 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,875
Why don't you shove the guts of the js into an external file and link it, just as the Stick said?
  Reply With Quote
Old 06-07-2004, 10:09   #18 (permalink)
blazedesigns
Senior Member
 
blazedesigns's Avatar
 
Join Date: Mar 2004
Location: Somewhere you can't find me
Posts: 101
OK, now i'm down to th following

Below are the results of attempting to parse this document with an SGML parser.

Line 18, column 140: required attribute "action" not specified

...eturn findinpage(this.string.value);">

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.



Line 19, column 133: end tag for "input" omitted, but OMITTAG NO was specified

...e="text" size="20" onchange="n = 0;">

You may have neglected to close a tag, or perhaps you meant to "self-close" a tag; that is, ending it with "/>" instead of ">".



Line 19, column 72: start tag was here

... <input name="string" type="text" size="2

Line 20, column 118: end tag for "input" omitted, but OMITTAG NO was specified

...pe="submit" value="Search Page"></div></td>



Line 20, column 72: start tag was here

... <input type="submit" value="Search Page"

Line 20, column 118: end tag for "form" omitted, but OMITTAG NO was specified

...pe="submit" value="Search Page"></div></td>



Line 18, column 72: start tag was here

...v align="center" class="smallheader"><form name="search" onsubmit="return fin
__________________
To recover from my internet addiction I will eat breakfast with a knife and fork and not with one hand typing.
  Reply With Quote
Old 06-07-2004, 10:10   #19 (permalink)
blazedesigns
Senior Member
 
blazedesigns's Avatar
 
Join Date: Mar 2004
Location: Somewhere you can't find me
Posts: 101
Quote:
Originally Posted by Bill Posters
Why don't you shove the guts of the js into an external file and link it, just as the Stick said?

I did, the problems are my own stupidity now.

Still not valid though
__________________
To recover from my internet addiction I will eat breakfast with a knife and fork and not with one hand typing.
  Reply With Quote
Old 06-07-2004, 10:18   #20 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,875
So, the invalidation errors are with your markup now, right?
(seeing as the javascript functions are no longer contained within the x/html doc)

What are the current errors?
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8