Log in

View Full Version : Javascript Onload HTML



davelf
01-03-2011, 03:47 AM
Hi, i have a problem to make script like this one:
https://www.sahabatnestle.co.id/kilau_fox/

or this one:

http://www.daniweb.com/forums/thread20849.html

i only know that i can use body="onload", but have no idea how to make it like that

I already searching some archive on dynamicdrive, but the only thing that close is this one :
http://home.comcast.net/~jscheuer1/side/lightbox2.04a/
Mr. John made this a couple time ago, but it's a lightbox.

So are there any recommendation, or example that i can use?

Thank you very much....:)

jscheuer1
01-03-2011, 04:28 AM
There are a number of scripts around that can do this. I currently favor FancyBox:

http://fancybox.net/

Another is LightWindow:

http://www.p51labs.com/lightwindow/

Dynamic Drive has its DHTML Modal window v1.1:

http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/dhtmlmodal.htm

There are many others. In the case of the first two, look through the documentation of each to find out how to launch one of them without a link.

The DD script already has a documented method to launch at load time.

One thing you should get away from though is:


body="onload"

Which isn't real code anyway, but implies using the onload attribute of the body tag to run a script onload of the page. Using the body onload attribute potentially conflicts with other scripts that might want to use it or the window onload event. There are more efficient ways than waiting for the entire page to load. FancyBox may use jQuery's document.ready method, for instance. That method will not conflict with other onload type events.

Pick a script that can do this and if you want more help, post a link to your best effort.

davelf
01-03-2011, 06:53 AM
thank you so much John, i used that fancy box, and work perfectly.

The dynamicdrive one is great too, but may be you need to add an extra function, so the user can click outside the box to close it, instead click on the close button. :p