We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17895
    • 209 Posts
    Hi all! How are you? smiley

    I’m trying to build a plugin but I need it to add a css file and a js file in the head. In a snippet, using $modx->regClientCSS(’somewhere.css’) and $modx->regStartupScript(’somewhereelse.js’) seem to work, but not in a plugin... any ideas?

    I also have to add a call to a js function in the <body onload="..."> attribute, can I do this in a plugin?

    Thanks
      Daniele "MadMage" Calisi
      • 22303 MODX Staff
      • 10,725 Posts
      On what event are you attempting to register the script/css with in your plugin?
        • 17895
        • 209 Posts
        Quote from: OpenGeek at Aug 27, 2007, 05:54 PM

        On what event are you attempting to register the script/css with in your plugin?

        OnWebPagePrerender... but now the question is: on what event I should attempt to register the script? smiley
          Daniele "MadMage" Calisi
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: madmage at Aug 30, 2007, 01:51 PM

          OnWebPagePrerender... but now the question is: on what event I should attempt to register the script? smiley
          Yeah, that’s too late; nothing is going to be injected at that point. Try OnLoadWebDocument instead.
            • 17895
            • 209 Posts
            Quote from: OpenGeek at Aug 30, 2007, 06:33 PM

            Quote from: madmage at Aug 30, 2007, 01:51 PM

            OnWebPagePrerender... but now the question is: on what event I should attempt to register the script? smiley
            Yeah, that’s too late; nothing is going to be injected at that point. Try OnLoadWebDocument instead.

            Yessss, now it works. thanks... how can I put a function call in the <body onload=""> attribute?
              Daniele "MadMage" Calisi