|
JavaScript Home
JavaScript TutorialIntroductionHow to Enable JavaScript JavaScript Syntax JavaScript Popup Boxes JavaScript and HTML External JavaScript File JavaScript Operators JavaScript Variables JavaScript Functions JavaScript Events JavaScript If Statements JavaScript Switch Statements JavaScript While Loop JavaScript For Loop JavaScript Try Catch JavaScript Escape Characters JavaScript Void(0) JavaScript Cookies JavaScript Date and Time JavaScript Arrays Two Dimensional Arrays JavaScript innerHTML JavaScript Summary JavaScript ReferenceJavaScript Reserved WordsJavaScript Event Handlers JavaScript Date and Time Functions JavaScript ExamplesList of ExamplesJavaScript Dropdown Menu JavaScript Print JavaScript Alert Box JavaScript Confirm JavaScript Prompt JavaScript Status Bar Messages Image Rollovers Popup Windows JavaScript Redirect Timed JavaScript Redirect JavaScript Refresh Page FREE Hosting!With every domain name you register with ZappyHost, you get FREE hosting.$1.99 Domain NamesWith every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99. |
JavaScript Popup WindowsYou can use JavaScript to create popup windows. Popup windows are different to simply opening a new browser window. If you only want to open a new browser window you can add the Basic JavaScript Popup ScriptHere is the basic script for generating a popup window: This code is best placed inside a function (see below). But first things first. Here's an explanation of the above code. The Basic Function for Popup WindowsYou can put the above code into a function, then call the function, passing the URL as a parameter, whenever you want to open a popup window. Doing this allows you to cut down on the amount of code you use when using popups. Here's a working example. The JavaScript: The above script creates a function that accepts a parameter called "url". You can now call the function in your HTML as follows. The HTML: Here, we create a normal HTML link, but we also add the The ExampleSo, putting the two together, our code should work like this: But wait! You can make your function even more portable by using the script below. A Better ScriptThis script is more versatile than the above script. This is because the function accepts parameters for more of the popup's properties (ie. height, width, position, name). This means you won't need to create a new function every time you want a different sized popup, a popup with a different name, or a popup in a different position. The above code creates the following link: Automatically Center your PopupThis function centers the popup in the middle of the users' screen. The JavaScript code will detect the screen size (each user could have a different screen size), then position the popup window in the center. So, if you need the popup centered in the middle of the users' screen, use the following code: The above code creates the following link: Enjoy this website?
Oh, and thank you for supporting Quackit! |
Need Content for your Website?Get unique, quality digital content for your website. You can even earn money by reselling it!Includes:
|