Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Calling javascript in the header

edited September 2006 in Vanilla 1.0 Help
do we just add the regular in the header or do we need to add some specal code tag, the head doesn't appear to look familiar mucho codeo

using nifty corners.js

Comments

  • This is what I found in the code of other extensions to add scripts and stylesheets in the head of the page: $Head->AddScript("extensions/yourExtension/yourFile.js"); $Head->AddStyleSheet("extensions/yourExtension/yourFile.css");
  • not sure if that's it, it doesn't add the tags in the head like the others do,

    I need to add one of these to the head section, its not an extension just a normal JS

  • I'm guessing $Head->AddString('<script type="text/javascript" src="niftycorners.js">'); would do the job.
  • in addition to that there needs to be a call inside the page itself like this before the </head> <script type="text/javascript"> window.onload=function(){ Nifty("div#box","big"); } </script> I added the one .js to init_vanilla.app that seem to do the trick for the one url but this one above might be tricky
  • What "$Head->AddScript("yourFile.js");" exactly adds to the header is:


    To achieve what you want you may try adding into youFile.js something like this (it is what I did in the DiceRoller extension, like old DOS resident applications initialization):

    // Store the pointer to any previous onload function before registering mine
    var oldWindowOnLoad = window.onload;
    window.onload = yourFunction;

    ...

    function yourFunction() {
    ... do whatever ...

    // Last line, call other registered onLoad functions
    oldWindowOnLoad;
    }

    This will execute your function on page load, and will also execute other previous onload function/s. If everyone who wants to add an onload function do this trick, all of them will be executed.
  • edited September 2006
    not sure if that will work I tried it and nothing happen,

    I believe in order for nifty corners to work, this has be just before the head tag as is

    <script type="text/javascript"> window.onload=function(){ Nifty("div#box","big"); } </script>
    but I' not certain for sure, that's the way its normally called
This discussion has been closed.