Tags:
create new tag
, view all tags
This page does not load properly. It shows what happens when I try to embed a piece of JavaScript. The JavaScript worked fine when I used it on a HTML page before. I think there is a bug in TWiki as:
  1. it interferes with the HTML comments
  2. when the comments are taken out the pages still fail to load properly.

I'll continue to see if I can figure out what it wrong...

Cheers.. M

<!-- Start of TheCounter.com Code --> 
  <SCRIPT><!--
s="na";c="na";j="na";f=""+escape(document.referrer)
//--></SCRIPT>
  <SCRIPT language="javascript1.2"><!--
s=screen.width;v=navigator.appName
if (v != "Netscape") {c=screen.colorDepth}
else {c=screen.pixelDepth}
j=navigator.javaEnabled()
//--></SCRIPT>
  <SCRIPT><!--
function pr(n) {document.write(n,"\n");}
NS2Ch=0
if (navigator.appName == "Netscape" &&
navigator.appVersion.charAt(0) == "2") {NS2Ch=1}
if (NS2Ch == 0) {
r="&size="+s+"&colors="+c+"&referer="+f+"&java="+j+""
pr("<A HREF=\"http://www.TheCounter.com\" TARGET=\"_top\"><IMG")
pr("BORDER=0 SRC=\"http://c1.thecounter.com/id=511050"+r+"\"></A>")}
//--></SCRIPT>
</h2>

<NOSCRIPT><A HREF="http://www.TheCounter.com" TARGET="_top"><IMG
SRC="http://c1.thecounter.com/id=511050" BORDER=0></A>
</NOSCRIPT>
<!-- End of TheCounter.com Code -->

Gets turned into this:

<SCRIPT>&lt;!--
s="na";c="na";j="na";f=""+escape(document.referrer)
//--&gt;</SCRIPT>
  <SCRIPT language="javascript1.2">&lt;!--
s=screen.width;v=navigator.appName
if (v != "Netscape") {c=screen.colorDepth}
else {c=screen.pixelDepth}
j=navigator.javaEnabled()
//--&gt;</SCRIPT>
  <SCRIPT>&lt;!--
function pr(n) {document.write(n,"\n");}
NS2Ch=0
if (navigator.appName == "Netscape" &amp;&amp;
navigator.appVersion.charAt(0) == "2") {NS2Ch=1}
if (NS2Ch == 0) {
r="&amp;size="+s+"&amp;colors="+c+"&amp;referer="+f+"&amp;java="+j+""
pr("<A HREF=\"http://www.TheCounter.com\" TARGET=\"_top\">&lt;IMG")
pr("BORDER=0 SRC=\"http://c1.thecounter.com/id=511050"+r+"\"&gt;</A>")}
//--&gt;</SCRIPT>
</h2>
<p> 
<NOSCRIPT><A HREF="http://www.TheCounter.com" TARGET="_top">&lt;IMG
SRC="http://c1.thecounter.com/id=511050" BORDER=0&gt;</A>
</NOSCRIPT>

-- MartinCleaver - 03 Mar 2001

What TWiki version are you using? Up to the 01 Dec 2000 version you could not have <!-- ... --> HTML comments span over more then one line. The latest Beta version does allow that. Also, TWiki requires HTML tags to be on one line.

TWiki has never been designed to support JavaScript. Therefore I am changing the classification from BugReport to FeatureEnhancementRequest.

-- PeterThoeny - 05 Mar 2001

I explicitly don't want JavaScript active. It would make it too easy for someone to insert malicious JavaScript to harm browsers. IMHO only the webmaster should be putting JavaScript on pages.

For a discussion of JavaScript security issues, see GetRidOfJavaScript. JoachimDurchholz - 08 Feb 2002

-- ChrisRiley - 07 Feb 2002

Here's a little workaround if you want to use JavaScript. All you have to do is put the code between

<!-- <pre> -->
...Code here...
<!-- </pre> -->

This works because of the way TWiki handles the <pre> tags and comments.

As proof, I add the Javascript code here:

So if we really want to disable JavaScript in user provided content, we need to parse the one-line comments better, and have a way of handling <script> tags.

-- WoutMertens - 30 Jul 2002

As described in JavaScriptExecutionProblem, this is the recommended way to embed JavaScript in TWiki pages:

<script type="text/javascript">
<!-- Hide JavaScript and <pre> escape TWiki rendering
... your JavaScript goes here...
// Stop hiding and stop </pre> escaping TWiki rendering -->
</script>

-- PeterThoeny - 03 Feb 2004

Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r9 - 2005-07-16 - AndyGlew
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.