I'm working on a module that shows a modal window of some sort (I've used Colorbox so far, but I'm not attached to it) upon page load. I've gotten to the point where I need to make it display on page load and am now a little bit stumped how I'd do that -- any ideas? Using D7, btw.



I figured it out, it's pretty easy. See below:

function popupmessage_init(){       
    $colorbox_js = 'jQuery(document).ready(function(){ jQuery.colorbox({html: "<h1>Your Message Here</h1>"}); });';
    drupal_add_js($colorbox_js, 'inline');      
| improve this answer | |
  • 1
    you can even pass extra parameters to style the colorbox window (width, height) – NenadP Sep 28 '12 at 6:44

I am not quite sure what you need but i use Colorbox extensivly. I even show nodes in pop-up windows, without layout, by sending parameter in url which basically says "use other page layout for this link". It is tricky though, to break from this kind of windows.

For one time popup, i just use cookies, jquery and colorbox in combination.

I found also http://drupal.org/project/popup module very useful for some needs.

Also you have Jquery UI modal http://jqueryui.com/demos/dialog/ .

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.