[Greasemonkey] including javascriptreferences in HEAD (overlib)

rupert rupert_apsc at rupespad.com
Tue Nov 1 21:02:18 EST 2005


I'm trying to develop a GM script which uses overlib to display  
popups and I can't seem to get things to work properly - so any help  
appreciated.

I'm using the following GM script:

(function()
{
     function initialiseOverlib()
     {
         // add the overLib script to the page header
         var overlibScript = document.createElement("script");
         overlibScript.setAttribute("type", "text/javascript");
         overlibScript.setAttribute("src", "http://www.rupespad.com/ 
scripts/overlib.js");
         overlibScript.appendChild(document.createTextNode("<!--  
overLIB (c) Erik Bosrup -->"));
         var head = document.getElementsByTagName('head')[0];
         if (head)
         {
             head.appendChild(overlibScript);
         }

         // add the div for displaying overlib boxes
         var overdiv = document.createElement("div");
         overdiv.setAttribute("id", "overDiv");
         overdiv.setAttribute("style", "position:absolute;  
visibility:hidden; z-index:1000;");
         document.getElementsByTagName("body")[0].insertBefore 
(overdiv, document.getElementsByTagName("body")[0].firstChild);
     }

     initialiseOverlib();

})();

to insert the vavascrip element into the HEAD and the overlib div  
into the BODY.

an example page it doesnt' work with is at http://www.rupespad.com/ 
testover.html

which contains the following:

<html>

     <head>
         <meta http-equiv="content-type" content="text/ 
html;charset=ISO-8859-1">
         <title>rupespad : test page</title>
     </head>

     <body>
         <h1>test heading</h1>
         <p>
             Here's a <a href="http://www.rupespad.com/flogg/"  
onmouseover="return overlib('content', NOCLOSE, CAPTION, 'title');"  
onmouseout="return nd();">link</a>.
         </p>

     </body>
</html>

All the stuff seems to be in the DOM where I epxect it, but I'm not  
getting the popup when I hover over the link.  Arggghhh - driving me  
crazy so any help muchly appreciated.  This is in fact a cut-down  
version of what I really want to do (in the real app, the link  
containing the onmouseover is generated by GM) but as I can't get  
either case to work, this seemed like the simplest to ask for help  
on....

Cheers

Rupert




More information about the Greasemonkey mailing list