SID-00715: How to embed Javascript in a page?
| Status: |
Answered |
TWiki version: |
4.3.2 |
Perl version: |
|
| Category: |
CategoryJavaScript |
Server OS: |
|
Last update: |
15 years ago |
For the life of me I can't get
JavaScript to work!
I edit a page, click "Edit HTML Source", and get the HTML editor as expected.
I add this to the HTML: <script type="text/javascript"> alert(0); </script>
Pretty vanilla stuff... should just pop an alert on page load.
I click "Update" and the JS isn't displayed in the WYSIWYG editor (perhaps expected).
I save the edit.
The newly edited content is rendered, but I get no popup.
I click Edit again. The JS now appears in WYSIWYG view as <script type="text/javascript">// </script>
Viewing it in TWiki Markup mode this is:
<script type="text/javascript">// <![CDATA[ alert(0); // ]]></script>
Viewing the HTML source it's:
<p><span class="WYSIWYG_PROTECTED"><script type="text/javascript"></span>// <![CDATA[ alert(0); // ]]><span class="WYSIWYG_PROTECTED"></script></span></p>
It seems that somewhere along the line the JS is being converted from script code (that can execute) to "a displayed representation of
JavaScript" (which looks nice but does nothing).
So, what's the trick to editing
JavaScript that gets saved as javaScript and therefore actually executes?
--
DaveChambers - 2010-01-13
Discussion and Answer
Try the <sticky>..</sticky> tags to delimit HTML (or TML) that you do not want to be WYSIWYG edited. See
TinyMCEPlugin.
--
PeterThoeny - 2010-01-15
Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the
TWiki consultants if you need timely help. We invite you to
get involved with the community, it is more likely you get community support if you support the open source project!
--
PeterThoeny - 2010-03-04
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.