Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2002, 09:51 AM   PM User | #1
Kennis
New to the CF scene

 
Join Date: Jul 2002
Location: Dublin, Ireland
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Kennis is an unknown quantity at this point
XHTML and scripting

I'm just getting to grips with XHTML standards at the moment. It's fairly straightforward making basic HTML compliant to XHTML but what are the specifications/rules for making sure that all scripts (javascript, DHTML, etc.) are compliant to XHTML? Is scripting handled differently or even accounted for?
Kennis is offline   Reply With Quote
Old 07-05-2002, 01:00 PM   PM User | #2
Zvona
Regular Coder

 
Join Date: May 2002
Location: Helsinki, Finland
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Zvona is an unknown quantity at this point
Not really. XHTML is used for defining structure of a document, which won't directly affect on scripting. I've noticed minor style differences with CSS between HTML 4.01 DTD and XHTML 1.0 DTD.
__________________
Zvona
First Aid for
Web Design
Zvona is offline   Reply With Quote
Old 07-05-2002, 06:09 PM   PM User | #3
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
One thing to be careful about:

<script type="text/javascript">
if (something < bla) {
// ....
}
</script>

Suddenly your document becomes invalid. Because Javascript extensively uses the <, >, and & signs, you either need to replace all occurrences of them with:
&amp;lt; --> "<"
&amp;gt; --> ">"
&amp;amp; --> "&"

But since that will definitely cause issues with browsers not truely supporting XHTML, you put the entire script in a <![CDATA script contents ]]> section. Once again though you run into older browser support, which is finally solved by a little hack:

<script type="text/javascript">
<!--// <![CDATA
//script contents
// ]]> -->
</script>


Also, if you dynamically generate any content, be sure you generate valid markup. (Using W3C DOM methods automatically takes care of it for you, but be wary with innerHTML and the such.)
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 07-06-2002, 04:00 AM   PM User | #4
Alex Vincent
Moderator


 
Join Date: May 2002
Location: Hayward, CA
Posts: 1,427
Thanks: 1
Thanked 19 Times in 17 Posts
Alex Vincent is on a distinguished road
Or you could always outsource your scripts...

<script language="JavaScript" type="text/javascript" src="myscript.js"></script>

That seems to be the easiest of all.
__________________
"The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
June 30, 2001
author, Verbosio prototype XML Editor
author, JavaScript Developer's Dictionary
https://alexvincent.us/blog
Alex Vincent is offline   Reply With Quote
Old 07-06-2002, 05:00 AM   PM User | #5
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Quote:
Originally posted by Alex Vincent
Or you could always outsource your scripts...

<script language="JavaScript" type="text/javascript" src="myscript.js"></script>

That seems to be the easiest of all.
True, but can be inconvenient at times.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:25 PM.


Advertisement
Log in to turn off these ads.