Multiple onload Events

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple onload Events

tom.giles
I can't seem to get shadowbox and jeroen's flv player to both load at the same time.  Without shadowbox I was loading the flv player using this method:

<body onLoad="createplayer('playlist.php', false)">


However, I found that this code breaks shadowbox.  If the onload code is removed leaving only <body> behind, the flv player obviously does not initialize, but shadowbox works.  I next tried this code in an attempt to combine both functions:


<script type="text/javascript"> Shadowbox.loadSkin('classic', 'shadowbox'); </script><script language="javascript"> function func1(){ Shadowbox.init; } function func2(){ createplayer('playlist.php', false); } function start(){ func1(); func2(); } </script></head>
<body onload="start()">


But that didn't work either.  The FLV player loaded, but shadowbox stopped working again.  Does anyone have any suggestions on how I can go about loading both functions?
Reply | Threaded
Open this post in threaded view
|

Re: Multiple onload Events

tom.giles
This also did not work:

<script type="text/javascript"> window.onload = function() { createplayer('playlist.php', false); Shadowbox.init; } </script><body>
Reply | Threaded
Open this post in threaded view
|

Re: Multiple onload Events

Wizzud
If you are calling the function it should be Shadowbox.init(); ... note the brackets!
Combine literacy with curiosity and a whole world of information opens up to you
Reply | Threaded
Open this post in threaded view
|

Re: Multiple onload Events

tom.giles
Oh boy do I feel sheepish, ha... I knew it had to be something simple.  Yes, that was my mistake, and simple oversight - thanks for catching it!
Reply | Threaded
Open this post in threaded view
|

Re: Multiple onload Events

p4ul
In reply to this post by tom.giles
I'm having the same problem. In your case, instead of this:

Shadowbox.init;

try

Shadowbox.init();

In my case, I'm using a function geared to allow multiple functions called onLoad without overwriting the previous (when i do it this way, my shadowBox linked content merely shows up in a new window):

function init()
{
        Shadowbox.init();
        startAjax();
}

//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func)
{
        var oldonload = window.onload;
        if (typeof window.onload != 'function')
        {
    window.onload = func;
        }
       
        else
        {
                window.onload = function()
                {
                        oldonload();
                        func();
                }
        }
}

addLoadEvent(init); // run onLoad
Reply | Threaded
Open this post in threaded view
|

Re: Multiple onload Events

p4ul
In reply to this post by Wizzud
In my case, I'm using a function geared to allow multiple functions called onLoad without overwriting the previous (when i do it this way, my shadowBox linked content merely shows up in a new window):

function init()
{
        Shadowbox.init();
        startAjax();
}

//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func)
{
        var oldonload = window.onload;
        if (typeof window.onload != 'function')
        {
    window.onload = func;
        }
       
        else
        {
                window.onload = function()
                {
                        oldonload();
                        func();
                }
        }
}

addLoadEvent(init); // run onLoad

// Prior to the above external js file, I load the following required files:
<script type="text/javascript" src="assets/js/shadowbox-base.js"></script><script type="text/javascript" src="assets/css/classic/skin.js"></script><script type="text/javascript" src="assets/js/shadowbox-2.0.js"></script>
//shadowbox-2.0.js is the file generated by the author's site to eliminate framework dependencies...
Reply | Threaded
Open this post in threaded view
|

Re: Multiple onload Events

p4ul
I figured it out.

I had to load the required skin js file AFTER the form built shadowbox-2.0.js but before the external file which runs the multiple onload code...

<script type="text/javascript" src="assets/js/shadowbox-base.js"></script><script type="text/javascript" src="assets/js/shadowbox-2.0.js"></script><script type="text/javascript" src="assets/css/classic/skin.js"></script>
<script type="text/javascript" src="assets/js/multipleOnload.js"></script>
PLUS I had to separately load the skin.css file as well using the above method...