JavaScript: Request for body's onload event:
flyingdutchie
Registered Users Posts: 1,286 Major grins
(I copied - i can not move it - this thread from customization... i think i belongs better here)
Hi smugmug,
In my customization i use the <body onload=""> event to execute code after the page finished loading (it creates a menu).
However, your 'slideshow' page overrides it because it contains javascript that forcefully overwrites the onload event-handler ==> My menu does not load. I got around it by doing some javascript hacking, but i'd prefer a proper solution :
Here is a snippet of the javascript from smugmug on the 'slideshow' page that overwrites it:
Maybe your smugmug.js scripting file could contain this piece of code:
The body tag must then look like this:
<body onload="executeOnLoad();">
And when some function needs to execute after the page has loaded, the registerOnLoad must be called:
Thank you very much.
-- Anton.
Hi smugmug,
In my customization i use the <body onload=""> event to execute code after the page finished loading (it creates a menu).
However, your 'slideshow' page overrides it because it contains javascript that forcefully overwrites the onload event-handler ==> My menu does not load. I got around it by doing some javascript hacking, but i'd prefer a proper solution :
Here is a snippet of the javascript from smugmug on the 'slideshow' page that overwrites it:
[b]onload = onStart;[/b] captionTopHidden = true; captionBottomHidden = true; ...
Maybe your smugmug.js scripting file could contain this piece of code:
var g_onLoadFncs = new Array(); function RegisterFunction(pFunction, pParameter) { this.funct = pFunction; this.parameter = pParameter; } function executeOnLoad() { for (var i = 0; i < g_onLoadFncs.length; i++) { var fnc = g_onLoadFncs[i]; fnc.funct(fnc.parameter); } } function registerOnLoad(pFunc, pParameter) { var curIndex = g_onLoadFncs.length; g_onLoadFncs.length++; g_onLoadFncs[curIndex] = new RegisterFunction(pFunc, pParameter); }
The body tag must then look like this:
<body onload="executeOnLoad();">
And when some function needs to execute after the page has loaded, the registerOnLoad must be called:
function myfunction(pParm) { ... } [b]registerOnLoad(myfunction, "hello");[/b] function myotherfunction() { ... } [b]registerOnLoad(myotherfunction);[/b]
Thank you very much.
-- Anton.
I can't grasp the notion of time.
When I hear the earth will melt into the sun,
in two billion years,
all I can think is:
"Will that be on a Monday?"
==========================
http://www.streetsofboston.com
http://blog.antonspaans.com
When I hear the earth will melt into the sun,
in two billion years,
all I can think is:
"Will that be on a Monday?"
==========================
http://www.streetsofboston.com
http://blog.antonspaans.com
0
Comments
JT
Please, notify me when you guys make that change, so that i can remove that hack from my scripting (otherwise the slideshow code will be launched twice).
Thanks!<img src="https://us.v-cdn.net/6029383/emoji/thumb.gif" border="0" alt="" >
-- Anton.
When I hear the earth will melt into the sun,
in two billion years,
all I can think is:
"Will that be on a Monday?"
==========================
http://www.streetsofboston.com
http://blog.antonspaans.com
<body onload="myfunction();">
On the slideshow page (or any other page we want to use javascript); you will end up with:
<body onload="slideshow(); myfunction();">
We have the same thing for classes and the body tag, if we detect you already have a class we automatically add ours.
however instead of this:
<body onload="slideshow(); myfunction();">
could you change it to this:
<body onload="myfunction(); slideshow();">
(myfunction() establishes my page (menu/logo/etc). I'd like to see that happening first, before the slideshow starts).
Thanks!
When I hear the earth will melt into the sun,
in two billion years,
all I can think is:
"Will that be on a Monday?"
==========================
http://www.streetsofboston.com
http://blog.antonspaans.com