Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

JavaScript-Editable

Summary: How to include JavaScript markup in wiki pages
Version:
Prerequisites:
Status:
Maintainer:
Categories: Markup
Users: +1 (View / Edit)

Question

Is it possible to include JavaScript markup in wiki pages?

Answer

Yes. 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.

Markup

You can use the custom markup in your local/config.php:

   Markup(
       'html',
       'fulltext',
       '/\\(:html:\\)(.*?)\\(:htmlend:\\)/mesi',
       "Keep(str_replace(array('&lt;', '&gt;', '&amp;'), array('<', '>', '&'),
       PSS('$1')))"
   );

This markup won't parse the text within (:html:) and (:htmlend:).

Example in your wiki page:

   (:html:)
   <script language="JavaScript">
       alert("Thanks to PM for that markup.");
   </script>
   (:htmlend:)

Notes

It must be stressed again and again that including JavaScript on an editable page could be dangerous.

See Also

Contributors

  • Luigi -> mailto:kirpi [snail] kirpi [period] it humbly reported from the Mailing Lists.
  • Torsten is the main contributor.

Comments

See discussion at JavaScript-Editable-Talk

Edit - History - Print - Recent Changes - Search
Page last modified on October 22, 2013, at 03:40 AM