Home » Forum
NoNumber!

Joomla!® Websites & Extensions
development  -  support  -  consultancy

I try to respond within 48 hours (excluding weekends).
If I haven't responded by then, feel free to post a reminder or bug me via email.

My last reply was: 3 Hours, 1 Minute ago.

Welcome, Guest
Please Login or Register.    Lost Password?

How to call a script when the page loads
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: How to call a script when the page loads
#6536
How to call a script when the page loads 2 Years ago  
I have inserted a slide show script on to a page. For the script to work the script needs to be called when the page loads. Normally I would include this in the body tag: <body onLoad="runSlideShow()">. What is the proper way to do this with Joomla!/Sourcerer? I could just add that to the template's index.php file, but on pages where I don't use the script I do't want to be calling a script that doesn't exist, do I?
Gary Girolimon
Posts: 6
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#6539
Re:How to call a script when the page loads 2 Years ago  
Best is to do this via mootools. Just check if the mootools script is loaded in your site. But you can add the first line to make sure it does:
{source}<?php
    JHTML::_( 'behavior.mootools' );
    $script = "
        window.addEvent( 'domready', function(){
            runSlideShow();
        });
    ";
    $doc =& JFactory::getDocument();
    $doc->addScriptDeclaration( $script );
?>{/source}
Peter van Westen
Admin
Posts: 9169
User Online NowClick here to see the profile of this user
Last Edit: 2010/01/15 20:35 By peter.
The administrator has disabled public write access.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
#6541
Re:How to call a script when the page loads 2 Years ago  
Thank you. Works like a charm!
Gary Girolimon
Posts: 6
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1
Moderators: Peter van Westen
MaxCDN | Content Delivery Network | Accelerate your site to the max
hosting joomla
Open Source Training | Online Joomla! Training and Support