Re: New Help with Javascript Navigation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2006-04-26 at 17:18, Jochem Maas wrote:
> <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.

Been there, done that technique... unfortunately it can't be used to
dynamically load script that will be "seen" by the currently executing
scope... this isn't quite true... I think one browser saw it right off,
another saw it if I used eval on the retrieved source, but other
browsers don't see it until after the scope (function scope) exits. The
exact semantics are quite varying which provides for completely
unreliable loading of dyanamic script -- and to be frank I try to make
my stuff work with IE/FF/Opera. I could care less about NN4 in this day
and age :)

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux