|
|
|
Joined: Aug 2000
Posts: 335
Member
|
Member
Joined: Aug 2000
Posts: 335 |
Example A: 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]<body onload="javascript:window.location='http://example.com/';"> [/qb] 3) Is the 'javascript:' prefix required here? 4) Should the attribute be 'onload' or 'onLoad'?
|
|
|
|
Joined: Mar 2001
Posts: 7,394
Admin / Code Breaker
|
Admin / Code Breaker
Joined: Mar 2001
Posts: 7,394 |
1. It doesn't matter, but type should be text/javascript, not text/plain 2. Yes, it's actually required 3. No 4. onload.
|
|
|
|
Joined: May 2000
Posts: 1,356
Addict
|
Addict
Joined: May 2000
Posts: 1,356 |
quote: 4.8 Script and Style elementsIn 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]<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
Admin / Code Breaker
|
Admin / Code Breaker
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... ?
|
|
|
|
Joined: Mar 2001
Posts: 7,394
Admin / Code Breaker
|
Admin / Code Breaker
Joined: Mar 2001
Posts: 7,394 |
I used: <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 
|
|
|
|
Joined: Aug 2000
Posts: 335
Member
|
Member
Joined: Aug 2000
Posts: 335 |
LK - thanks for answering my questions. What is this CDATA stuff? Does that matter for what I'm doing? 
|
|
|
|
Joined: Mar 2001
Posts: 7,394
Admin / Code Breaker
|
Admin / Code Breaker
Joined: Mar 2001
Posts: 7,394 |
jeo, W3C standards should be supported in IE6 
|
|
|
|
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.
|
|
|
|
Joined: Mar 2001
Posts: 7,394
Admin / Code Breaker
|
Admin / Code Breaker
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 
|
|
|
|
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? @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 & and < 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
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. 
|
|
|
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.
|
|
Posts: 449
Joined: February 2008
|
|
Forums63
Topics37,575
Posts293,930
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|
|
|
|