Launching Shadowbox onload --how do I get it to load a page?

mountaingirl picture mountaingirl · Jul 22, 2011 · Viewed 7.3k times · Source

I've used Shadowbox on a link many times and understand that the href directs Shadowbox as to what page load in the box like this:

<a rel="shadowbox;width=700;height:500;" id="something" href="/page/iwantto/load/here.php">

However, I now need to have a shadowbox appear as soon as users come into the page. Not onclick, but onload.

I am using the following code:

    window.onload = function() {
    // open a welcome message as soon as the window loads
  Shadowbox.open({
      content:    '<div><a href="/some/path/here.php">Clicky</a></div>',
      player:     "html",
      title:      "A Title",
      height:     600,
      width:      700
  });

};

which comes from http://www.shadowbox-js.com/usage.html

As anyone who knows shadowbox better than I do realizes...this results in a black shadowbox with the linked word "clicky" and when you click, the parent page directs to the link.

I apologize for asking such a basic question on here but I've googled for a few hours and read through a bunch of stuff on shadow-js.com and I'm not finding the syntax I need to get the onload shadowbox to open up the link. I've tried adding this line:

link:       '/some/path/here.php',

but that's not it either. I also read a bit about .setup but do not totally understand how to use it. If anyone can point me in the right direction for a tutorial or explain some code that would be great. Thank you.

Answer

Jonathan Calb picture Jonathan Calb · May 18, 2012

Content its also wrong, and title its not neccesary.

window.onload = function() {
  Shadowbox.open({
      content:    'some/path/here.php',
      player:     "iframe",
      height:     600,
      width:      700
  });

};