Creating popup windows in JS |
Article is yet to be rated |
|
| Author:
| C i R I
|
|
| Submitted: |
29-Sep-2002 06:59:23 |
| Imported From: |
zZine (original author: ciri)
|
| First of all, before creating popups, keep in mind how irritating popups can be, but i guess you knew that already right ? Well, let's begin. I'm now supposing you have a very basic knowledge of JavaScript and/or HTML.
|
|
You can define popup windows in several ways, the most known one however is "window.open". The basic syntax is:
window.open("some_url");
Where some_url is the url of the popup window. This would display a standard user-defined window. You can however change the windows height, width, etc ...
Let's make some example windows:
window.open("some_url","window_name","location,menubar");
You'll get a window with just the location box (the place in your browser where you type in a URL) and a menu bar (File, Edit, etc.).
window.open("some_url","window_name", "height=100,width=100");
I guess this speaks for itself doesn't it ? Anyway, i guess you got the hang of it now.
Here's a list of the features that you can include in the feature string:
menubar
This is the row of functions that appears on most software applications. Normally it includes File, Edit, and a few other items.
status
This is the message bar at the bottom of your window. When you move your mouse over an HTML link, the URL appears in the status bar. You may have seen pages that use JavaScript to turn this status bar into a scrolling marquee. I'm not going to show you how to do this. If you want to know, you have to figure it out yourself. "Down with marquees," the monkey cried!
scrollbars
This allows scrollbars to appear when necessary.
resizable
If resizable is listed, the window can be resized. Be careful of the spelling. I always get it wrong.
width
The width of the window in pixels.
height
The height of the window in pixels.
toolbar
The browser toolbar, which contains the Back and Forward buttons, the Stop button, and the Home button, among others.
location
The text area of a browser into which you can type URLs.
directories
The directories that Netscape browsers have called "What's new," "What's cool," and so on.
Why popups can be irritating:
While opening 1000 popup windows a malicious web builder could crash the visitors system (or at least internet). I can hear you asking "How can he do that ?". Well, very easy, by creating a window.open loop as i call it. Here's the code below:
--> Begin of "cool.html"
x = 0;
while (x < 1001)
{
window.open("cool.html");
x++;
}
--> End of File
this would popup 1000 windows, each of those windows would execute the same code an create again 1000 windows each. So let's way you would have 1000^1000 popups ! Mooha erm well, don't do that, 'cause it's not funny.
Enjoy!
Source: Google.com and my own mind =)
This article was originally published by CyberArmy.net in the CyberArmy Library.
|
|
You must be logged in to vote on an article
|
About Us | Privacy Policy | Mission Statement | Help
|