• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Trigger an overlay via JS

How would one go about triggering an overlay with Javascript? I could only find one post on this subject, and this is what I've got so far:
var $trigger = window.onload;
var $templateHtml = "test";
XenForo.createOverlay($trigger, $templateHtml).load();
But I'm getting this error:
Uncaught TypeError: Cannot call method 'refresh' of null xenforo.js:191
    c.extend.activate xenforo.js:191
    jQuery.fn.extend.xfActivate xenforo.js:177
    c.extend.createOverlay xenforo.js:199
    (anonymous function)
Am I going about this right?