Re: New Help with Javascript Navigation

From: Date: Wed, 26 Apr 2006 21:18:42 +0000
Subject: Re: New Help with Javascript Navigation
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-234867@lists.php.net to get a copy of this message
<BTW> Wez Furlong has written an ActiveScript compatible plugin that allows running php clientside in the browser - YMWV. </BTW> Robert Cummings wrote:
On Wed, 2006-04-26 at 16:47, Evan Priestley wrote:
... nice func Rob. :-) now onward to HELL ...
?> Unfortunately, you're going to have a HELL of a time with dynamically include()'ing source :)
function includeJS(jsPath) {
    // bogus URL/path to script?
    if (!isString(jsPath) || !jsPath) {
        return;
    }
    // remove extraneous spaces - just in case
    jsPath = jsPath.trim();
    // has the given script already been 'included'?
    var scripts = document.getElementsByTagName("SCRIPT");
    var scriptsLen = scripts.length;
    for (var i = 0; i < scriptsLen; i++) {
        if (scripts.src == jsPath) {
            // the requested file has already been added (or was defined/linked from the start.
            return;
        }
    }
    // everything is ok, lets include the script.
    var script = document.createElement("SCRIPT");
    script.setAttribute("type", "text/javascript");
    script.setAttribute("src", jsPath);
    document.getElementsByTagName("HEAD")[0].appendChild( script );
} probably far from perfect but it's helped me out of a jam now and again.

« previous php.general (#234867) next »