Initiating a Javascript without a "<body onload=" statement

Initiating a Javascript without a "<body onload=" statement

am 12.10.2011 04:51:58 von Bill Mudry

--=====================_46996845==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

I have been doing fairly well with authoring a cybermall that will be
for the purpose of inviting successful exotic wood companies to each
have their own store in my mall to sell a wide variety of exotic
woods. I will include the URL to the home page that I am working on
---- but please
understand this is NOT at all any attempt to do so to promote
anything. Instead, it is far easier to understand my objectives in
making part of the page have a background slide show since it is all
very graphic:
http://www.exoticwoodmall.com/index2.php

Note the reddish wood pattern background behind the cream coloured
section in front that has a title of "Exotic Wood Mall". It occurred to me
that it might be possible to have not a usual slide show but one that
runs in the background instead. I searched around the Net and found an
appropriate Javascript. Using different wood scans, I made a separate
page just to prove they could run in circulating manner (ie. slideshow)
and was successful;
http://www.exoticwoodmall.com/index2.php

This simple page loads the images into memory and rotates the active
picture after each set time-out. It is started by this tag:



Ie. it takes a body tag to get it going. This may be a common way of
starting such scripts but it will not
work on the home page where I want it (see above). I would rather
have this background slide action
happening only in the background area that is red. It is defined by a
div statement. I tried attaching the onload statement to the div with
no success. That area, also, is part of an include file, so there is
no traditional manner.

I looked around on the Net to see more what "onload" will work with.
The closest I came to was perhaps some
comments on using "readystate" which I am totally unfamiliar with. It
is well beyond any knowledge I have had for using Javascript.

So... Is there any solution or solutions to making this work that any
of you know? If we can get it to work,it could make for some really
neat theme making eye candy for many websites, my Exotic Wood Mall
included :-) :-). It does not have to be Javascript even if something
else works better.

..... I can include code from the page if really needed but it would
be better to attack the solution in a
more general way of how to start the script outright.

..... for all those Canadians out there, a slightly belated Thanksgiving!

Much thanks for all efforts,

Bill Mudry


--=====================_46996845==.ALT--

Re: Initiating a Javascript without a "<body onload=" statement

am 12.10.2011 11:21:53 von Richard Quadling

On 12 October 2011 03:51, Bill Mudry wrote:
> I have been doing fairly well with authoring a cybermall that will be for
> the purpose of inviting successful exotic wood companies to each have the=
ir
> own store in my mall to sell a wide variety of exotic woods. I will inclu=
de
> the URL to the home page that I am working on ---- but please
> understand this is NOT at all any attempt to do so to promote anything.
> Instead, it is far easier to understand my objectives in making part of t=
he
> page have a background slide show since it is all very graphic:
>        http://www.exoticwoodmall.com/index2.php
>
> Note the reddish wood pattern background behind the cream coloured sectio=
n
> in front that has a title of "Exotic Wood Mall". It occurred to me
> that it might be possible to have not a usual slide show but one that run=
s
> in the background instead. I searched around the Net and found an
> appropriate Javascript. Using different wood scans, I made a separate pag=
e
> just to prove they could run in circulating manner (ie. slideshow)
> and was successful;
>        http://www.exoticwoodmall.com/index2.php
>
> This simple page loads the images into memory and rotates the active pict=
ure
> after each set time-out. It is started by this tag:
>
>                 nBGSlideShow()">
>
> Ie. it takes a body tag to get it going. This may be a common way of
> starting such scripts but it will not
> work on the home page where I want it (see above). I would rather have th=
is
> background slide action
> happening only in the background area that is red. It is defined by a div
> statement. I tried attaching the onload statement to the div with no
> success. That area, also, is part of an include file, so there is no y
> .... statement on which to hang the onload blah blah in traditional manne=
r.
>
> I looked around on the Net to see more what "onload" will work with. The
> closest I came to was perhaps some
> comments on using "readystate" which I am totally unfamiliar with. It is
> well beyond any knowledge I have had for using Javascript.
>
> So... Is there any solution or solutions to making this work that any of =
you
> know? If we can get it to work,it could make for some really neat theme
> making eye candy for many websites, my Exotic Wood Mall
> included :-) :-). It does not have to be Javascript even if something els=
e
> works better.
>
> .... I can include code from the page if really needed but it would be
> better to attack the solution in a
> more general way of how to start the script outright.
>
> .... for all those Canadians out there, a slightly belated Thanksgiving!
>
> Much thanks for all efforts,
>
> Bill Mudry
>
>

The syntax is only to get the code running.

I use Prototype (JQuery will have a similar mechanism).

One of the ways in which to use Prototype is to ask it to watch for a
very specific event.

The event is the 'dom:loaded' event. You can see the documentation at
http://api.prototypejs.org/dom/document/observe/

So, something like ...


...







would be the same sort of thing.

If your slide show uses Prototype then it should start running just as
happily. If it uses JQuery, then choose the appropriate url from
http://code.google.com/apis/libraries/devguide.html for JQuery and the
UI (if used).

So, this will load the slideshow in a relatively standard way - it is
long been suggested that using HTML tag attributes to load JS code is
bad form.

Others say that the code that makes things all go should be loaded at
the bottom of the HTML content ...





Again, you have additional content in the HTML.

I prefer the document.observe() approach. Other opinions are
available, I'm sure.



For server side CSS and JS combining, take a look at
http://www.sonassi.com/knowledge-base/combine-and-compile-cs s-and-js-into-g=
zipped-files/

I've used a modified version of the initial work carried out by Rakaz
(http://rakaz.nl/projects/combine/combine.phps) for many years. This
new work on www.sonassi.com looks interesting.


Richard.

P.S. Initially I was going to send this offlist as this would seem to
be a JS issue only, but thanks to the JS and CSS combinator being PHP
code, I successfully pulled it back on list. But in truth, only just.



--=20
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

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