Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

119 users online



popup window

popup window

Currently viewing this thread: 1 (0 members and 1 guests)


Milkmaid

Milkmaid

'puter thangy newbie...hehe
Status: Offline!

popup window

argggg...maybe one of you js gurus can help me out here...
i'm having trouble with the code for a pop up window.
I want to be able to click on the link or image and have a small window pop up.
also can anyone recommend a good js book. i hate to have to keep asking you all when i need help with js. you're all so nice and always help me out. thanks so much.
mm

fredmv

fredmv

Status: Offline!

You just need to use the open method, and in the third argument of it you define the height/width and other window properties. So for something like this you just need to define height,width, and scrollbars since by default they aren't there when you open a new window.

For a basic text link.

Code:


<a href = "#" onclick = "window.open('file.html', '', 'height=200,width=300,scrollbars=1');">Open a 300x200 window.</a>

Then for an image - Basically the same thing only adding an <img> element to include the image.

Code:


<a href = "#" onclick = "window.open('file.html', '', 'height=200,width=300,scrollbars=1');"><img src = "image.gif" border = "0" alt = "" /></a>

And, about the JavaScript book, I'd suggest getting any of these three (I own all of them):

The Book of JavaScript&#58; A Practical Guide to Interactive Web Pages (Dave Thau)
Sams Teach Yourself JavaScript in 24 Hours (Michael Moncur)
JavaScript&#58; The Definitive Guide (David Flanagan)

I'd suggest getting one of the first two since the third is slightly more advanced, but extremely helpful and a great reference, has to be my favorite book on JavaScript so far.

Well - Good luck!

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

ZeroLasek

ZeroLasek

Status: Offline!

Hey MilkMaid.

This code is is easy and generates a popup window easily. I including some notes to help ya out.

Code:


<script language="javascript">
<!--
function popup(u, s, w, h) {
window.open(u, "", "width=" + w + ", height=" + h + ", scrollbars=" + s + ")
}
-->
</script>

Here is how to open your popup with a basic link:

Code:


<a href="javascript: popup('URL', 'SCROLLBARS? YES OR NO?', width, height);">Click to open!</a>

Here is how to open your popup with an image link:

Code:


<a href="javascript: popup('URL', 'SCROLLBARS? YES OR NO?', width, height);"><img src="IMAGE SOURCE" border="0"></a>

And here is the code to close your popup:

Code:


<a href="javascript: close();">Close Me</a>

I hope this helped! Grin

Terry

___________________

http://www.zerolasek.net

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0079 seconds.