|
Cookbook /
JavaScript-EditableSummary: How to include JavaScript markup in wiki pages
Version:
Prerequisites:
Status:
Maintainer:
Categories: Markup
QuestionIs it possible to include JavaScript markup in wiki pages? AnswerYes. Using this recipe you can embed JavaScript in your pages. However, keep in mind that allowing JavaScript (as well as html) on an editable wiki page is dangerous: code inserted by a malicious visitor could be quite harmful. In this case, password protecting the pages is a reasonable suggestion. MarkupYou can use the custom markup in your local/config.php:
Markup(
'html',
'fulltext',
'/\\(:html:\\)(.*?)\\(:htmlend:\\)/mesi',
"Keep(str_replace(array('<', '>', '&'), array('<', '>', '&'),
PSS('$1')))"
);
This markup won't parse the text within
Example in your wiki page: (:html:)
<script language="JavaScript">
alert("Thanks to PM for that markup.");
</script>
(:htmlend:)
NotesIt must be stressed again and again that including JavaScript on an editable page could be dangerous. Comments
This note already existed at the time this recipe page was created, but it was easy to overlook. The code there might work a little better because your block of code will not necessarily be <p>inside a paragraph</p>. Hagan
Using this script, I was able to add Google Translate to my sidebar. Not too shabby! - Aargau3 See AlsoContributors
|