Recent Topics

1 Jul 03, 2006 03:48    

At the end of each skin, before the </body> their should be:

<script type="text/javascript">
<?php $Plugins->trigger_event( 'JavascriptInit' ); ?>
</script>

So Plugins that are based upon javascript can initialize once the page has loaded the DOM.

An example plugin that is/will use this can be seen here (The Sidebars):
http://blogs.balupton.com/index.php?Lightality-%3EPanels-%3EAdvancedMode=true&Lightality-%3ESideBars-%3EEnabled=true

Cheers.

2 Jul 03, 2006 03:58

*puts overpriced beer down* wouldn't it make more sense to have :-

<?php $Plugins->trigger_event( 'HtmlEndBody' ); ?>

The plugin could write the <script></script> tags, and it would give a smidge more flexability.

*wanders off to find EdB's secret stash of JB*

¥

3 Jul 03, 2006 04:01

Yeh, i've been fidling and deciding about wether to use endbody instead, but the only things that would go in endbody would be javascripts.

And it sure saves the repetitive <script .... for each plugin that needs it.

*Leaves to buy a six pack of cheap lager, you're killin me*

4 Jul 03, 2006 15:49

Perhaps I'm a bit confused, but why would you use a client-side script to trigger a server-side action? Isn't it much better to do all the server side stuff at the server? Either way, it'll fail when the visitor doesn't allow javascripts.

Skins that depend on javascript should carry a warning label.

5 Jul 03, 2006 18:58

What's bad with using the SkinBeginHtmlHead() event and outputting


<script type="text/javascript">
  addEvent( document, "load", my_function, false|true );
</script>


there? This will add it to the document's onload events..

6 Jul 03, 2006 19:26

I believe that waits for the whole page to load, not just the dom. So the javascript would be waiting for images to load as well, which could take a while...

7 Jul 28, 2006 07:48

blueyed wrote:

What's bad with using the SkinBeginHtmlHead() event and outputting


<script type="text/javascript">
  addEvent( document, "load", my_function, false|true );
</script>


there? This will add it to the document's onload events..

That does not work with firefox...

Although this does;

function addLoadEvent(func) {
	// taken from; http://simon.incutio.com/archive/2004/05/26/addLoadEvent
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
		if (oldonload) {
			oldonload();
		}
			func();
		}
	}
}

addLoadEvent(init);


Form is loading...