[dokuwiki] Javascript Dom question in /conf/userscript.js

  • From: "[list] Riny" <list@xxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Mon, 12 Jun 2006 19:20:19 +0200

I have a question on the usage of userscript.js

I want to add a toolbar button with the current ID in it, and I tried
Andi's tip on http://wiki.splitbrain.org/wiki:tips:toolbarbutton

There it says:
>> The current page ID is in a hidden field of the edit form which you
>> could access from your JavaScript. Just pull it from there.

so my userscript.js is:

if(toolbar){
        var xid = document.getElementsByName("id");
        var ns=xid[1].value;
        var open = "[["+ns+":";
        toolbar[toolbar.length] = {"type":"format",
                             "title":"newpage_below",
                             "icon":"below.png",
                             "key":"",
                             "open":open,
                             "close":"]]"};
}


The problem is though that apparently the document is not yet loaded
when userscript.js gets evaluated. So the xid[] array will always be empty.

I guess I'm making some mistake here.

Any suggestions would be very appreciated.

Riny
-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: