[Phpwm] [OT]event trigger

Phil Beynon phil at infolinkelectronics.co.uk
Thu Mar 15 01:50:20 GMT 2007


> Yeah as david said, really nowerdays we're (as in web developers
> as a whole)
> are (or should be) trying to keep javascript out of html pages. What you
> then do is install the hooks using the javascript. As a rule of thumb this
> is done in "window.onload".

Agreed, which in most cases, as I just said in a previous email, it is. In
fact looking through it that little script is just about the only bit now
which is inline. I might see if I can shove that to the top later, not sure
in its current form if its going to work outside the form tags without
modification, dunno, will play and see.

Hehe - I've got a definite feeling that when I say I'm writing a CMS that
people might have a few prejudged misconceptions as to exactly what its
going to be :-)

Phil


>
>
> An example might be:
>
> ### init.js ###
> window.onload = init();
>
> function init() {
>     document.getElementById('foo').onmouseove = barr();
>     // etc.
> }
>
>
> function foo() {
>     // function body...
> }
>
> ### end ###
>
> ### index.php ###
> <html>
>     <head>
>         <script type='javascript' src='init.js'></script>
>     </head>
>     <body>
>         <!-- Page Content -->
>     </body>
> </html>
>
> ### end ###
>
> Although if you were to do it properly I believe you should try
> addEventListner() or something first. But that's just good practise.
>
> Hope this helps,
> from Paul
> _______________________________________________
> Phpwm mailing list
> Phpwm at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/phpwm
>




More information about the Phpwm mailing list