Search code examples
javascripthtmlsharepointwiki

How to enter Javascript into a wiki page?


How can I, as the wiki admin, enter scripting (Javascript) into a Sharepoint wiki page?

I would like to enter a title and, when clicking on that, having displayed under it a small explanation. I usually have done that with javascript, any other idea?


Solution

  • Assuming you're the administrator of the wiki and are willing display this on mouseover instead of on click, you don't need javascript at all -- you can use straight CSS. Here's an example of the styles and markup:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
      <title>Test</title>
      <style type="text/css">
        h1 { padding-bottom: .5em; position: relative; }
        h1 span { font-weight: normal; font-size: small; position: absolute; bottom: 0; display: none; }
        h1:hover span { display: block; }
      </style>
    </head>
    <body>
      <h1>Here is the title!
        <span>Here is a little explanation</span>
      </h1>
      <p>Here is some page content</p>
    </body>
    </html>
    

    With some more involved styles, your tooltip box can look as nice as you'd like.