Previous Thread
Next Thread
Print Thread
Rate Thread
#109510 10/05/2002 7:05 AM
Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
Example A:
Quote
code:
Code
<script language='javascript' type='text/plain'>
<!--
... javascript here
//-->
</script>

1) Should the language attribute be 'javascript' or 'Javascript'?

2) Is the type attribute recommended?

Example B:
code:
[qb]
Code
<body onload="javascript:window.location='http://example.com/';">
[/qb]
3) Is the 'javascript:' prefix required here?

4) Should the attribute be 'onload' or 'onLoad'?

Sponsored Links
Joined: Mar 2001
Posts: 7,394
LK Offline
Admin / Code Breaker
Admin / Code Breaker
Offline
Joined: Mar 2001
Posts: 7,394
1. It doesn't matter, but type should be text/javascript, not text/plain tipsy

2. Yes, it's actually required tipsy

3. No

4. onload.

#109512 10/05/2002 12:56 PM
Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
Quote
quote:
4.8 Script and Style elements

In XHTML, the script and style elements are declared as having #PCDATA content. As a result, <
and & will be treated as the start of markup, and entities such as < and & will be
recognized as entity references by the XML processor to < and & respectively. Wrapping the
content of the script or style element within a CDATA marked section avoids the expansion of
these entities.
code:
[qb]
Code
<script>
<![CDATA[
... unescaped script content ...
]]>
</script>
[/qb]
CDATA sections are recognized by the XML processor and appear as nodes in the Document
Object Model, see Section 1.3 of the DOM Level 1 Recommendation [DOM] [p.29] .
An alternative is to use external script and style documents.

Joined: Mar 2001
Posts: 7,394
LK Offline
Admin / Code Breaker
Admin / Code Breaker
Offline
Joined: Mar 2001
Posts: 7,394
Jeo, I noticed it a while ago and tried it myself, and it didn't work...

Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
well what do you mean by "didnt work" ? if you have ampersands in the code, you must use cdata thingy... ?

Sponsored Links
Joined: Mar 2001
Posts: 7,394
LK Offline
Admin / Code Breaker
Admin / Code Breaker
Offline
Joined: Mar 2001
Posts: 7,394
I used:
Code
<script type="text/javascript">
<![CDATA[
something
]]>
</script>
And it simply didn't do the "something", it ignored it. The best way is

Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
hmm... that looks like a browser problem not code... I didnt have a problem with anyway, the manual says "use it like this", but you can select the way of coding yourself smile

Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
LK - thanks for answering my questions. smile

What is this CDATA stuff? Does that matter for what I'm doing? confused

Joined: Mar 2001
Posts: 7,394
LK Offline
Admin / Code Breaker
Admin / Code Breaker
Offline
Joined: Mar 2001
Posts: 7,394
jeo, W3C standards should be supported in IE6 tipsy

#109519 10/06/2002 11:20 AM
Joined: Jan 2000
Posts: 5,073
Admin Emeritus
Admin Emeritus
Joined: Jan 2000
Posts: 5,073
IE6 does not support XHTML - it just fakes it. Try serving it an XHTML page served as text/xml...


UBB.classic: Love it or hate it, it was mine.
Sponsored Links
#109520 10/06/2002 12:05 PM
Joined: Mar 2001
Posts: 7,394
LK Offline
Admin / Code Breaker
Admin / Code Breaker
Offline
Joined: Mar 2001
Posts: 7,394
If the most used browser (>90%) doesn't support it, I don't see any reason to use it for 1/10 of your visitors tipsy

Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
@LK;

You must select one; a cr@p browser or standards? tipsy

@Dave;

XHTML is an extended version of HTML 4.01 and it uses some XML specifications... If your javascript has some '&' or '<' in it, you must either convert them to &amp; and &lt; or escape them with CDATA...

http://www.w3.org/TR/xhtml1/

You can get the manual in pdf format => http://www.w3.org/TR/xhtml1/xhtml1.pdf

Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
jeologic:

If your javascript has some '&' or '<' in it, you must either convert them to & and < or escape them with CDATA...

I assume that applies only when those characters are used in strings representing URLs, and not when they're used as Javascript operators, e.g., if (x < 5)?

I'm still not clear whether this applies to my questions in the first post. confused


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)