You are not logged In.
LOGINREGISTER
FORGET PASSWORD
Calling Javascript functions from PHP
If you have designed websites using jQuery, you might have noticed that you are limited to showing certain sections/parts of your websites with direct URL. This is due to the fact that it is mostly user interaction of clicking, mouseover, etc..

This is a small function that will allow you to call certain Javascript functions passed in the URL parameters.

For example, if I would want a user to view the login screen I have on my website, they would visit:

http://www.azizsaleh.com/index.php/?js=login

To pass parameters (pipe delimited), use:

http://www.azizsaleh.com/index.php/ResumeAndPortfolio/?js=showSection&jsp=2


PHP Code: <?php

<script type="text/javascript">
$(
document).ready(function() {
    // Check for JS by URL
    // by azizsaleh @ azzisaleh.com
                             
    
<?php
    
// Check if there is a javascript function
    if(isset($_GET['js']))
    {
        // set a time out @ 100 milliseconds
        $js 'setTimeout("';
        $js .= $_GET['js'].'(';
        
        
// Check for function paramters
        if(isset($_GET['jsp']))
        {
            // Print variables
            $jsParamters explode('|',$_GET['jsp']);
            for($x=0;$x<count($jsParamters);$x++){ $js .= "'".$jsParamters[$x]."',";}
            if(strlen($js) > strlen($_GET['js'])+13    ){ $js substr($js,0,-1);}            
        
}
        $js .= ')",100);';
        echo $js;
    }
    ?>
    
});
</script>

?>

Attachments
© Aziz S. Hussain 2009, except where otherwise stated
Contact Me - My Resume & Portfolio - Privacy Policy - TOS