Welcome to WebmasterWorld Guest from 54.145.209.34

Forum Moderators: open

Xhtml 1.1 dtd

Disabling JS Function in Opera

   
1:47 am on May 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For some reason or another Opera 6 no longer sees this external JS function, it happened after updating my code with the XHTML 1.1 DTD. Netscape and IE present no problems. It does read the first JS function in my external script, so I'm thinking I might have something wrong below: (Of course, it all validates)?

<script type="text/javascript">
<!--
changePicture();
//-->
</script>

Thanks as always for ye help...

3:14 am on May 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When all else fails >> un-install :: re-install;)
8:16 am on May 26, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I never really do any js but I'm almost certain that you need to enclose the function in CDATA

<script>
<![CDATA[
function_here()
]]>
</script>

Nick

9:44 am on May 26, 2002 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Nick, this was new territory for me, so I did some research - you are exactly right. If you use <script> tags within the XHTML document, the format is exactly as you posted. External scripts called from the HEAD need no special treatment.

Here's the W3C reference on Differences Between HTML 4 and XHTML [w3.org]. Scroll down a bit for Item 4.8 - Script and Style Elements

(edited by: tedster at 1:15 pm (utc) on May 26, 2002)

10:22 am on May 26, 2002 (gmt 0)

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Me, too. I've never used it but just remember reading the theory a while back. Using that method can, apparently, be a little tricky with old browsers though.

Nick

3:53 pm on May 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Both IE6 and Opera6 failed to implement this method. Of course, I might of missed something...

Thanks for the link Tedster-

5:37 pm on May 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<script type="text/javascript">
//<![CDATA[
changePicture();
//]]>
</script>

:: // -- Will keep <![CDATA[]]> from halting your JS.
:: IE6 NN6.2/7 Opera6;)

Doing a search on "PCDATA" and "CDATA" on SEW will present excellent info on the subject.

7:37 pm on May 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've read the W3C reference as well, and since the few javascripts I use are all external, I have not had the need to use the CDATA designation.

Without a doubt there are going to be more than a few "stubbed toes & scraped knuckles" until Web developers migrating to XHTML become familiar with the requirements for embedded javascript. Time for a "HEADS UP!"

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month