This article gives you the basics of designing, opening, and closing browser windows using Java Script. In future articles, I will show you how to do all kinds of annoying things with windows using Java Script.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact Advertise on Bucaro TecHelp Advertise Here RSS News Feeds News Feeds

HTML5 Solutions: Essential Techniques for HTML5 Developers

Essential Techniques for HTML5 Developers

HTML5 brings the biggest changes to HTML in years. Web designers now have new techniques, from displaying video and audio natively in HTML, to creating realtime graphics on a web page without a plugin.

This book provides a collection of solutions to all of the most common HTML5 problems. Every solution contains sample code that is production-ready and can be applied to any project.

Click Here

Easy Java Script Windows

<script>open()</script>

When you open your web page, a popup window named about:blank will appear.

In the code above we have used the fact that the browser defaults to Java Script. Proper coding would have specified the script language and assigned the window to a variable so that we could use that variable to control the window after we create it. The example below shows the proper code to create a window and load a web page named mypage.htm into the window.

<script language="JavaScript">
var myPopUp = window.open("mypage.htm","pop_window");
</script>

Of course, you don't have to load a local web page into the window, you can put any URL in the first argument of the window.open function. Note the second argument of the window.open function, "pop_window". This gives the window a name that you can use to load a different page into the window, as shown below.

<a href="mypage2.htm" target="pop_window">Link Text</a>

You can add a third argument, called the "features list", to the window.open function. Below is a list of the features that you can specify.

leftlocation of the left border of the window in pixels from the left side of the screen
toplocation of the top border of the window in pixels from the top of the screen
widthwidth of the window in pixels
heightheight of the window in pixels
menubarspecifies the menu bar
toolbarspecifies the tool bar
locationspecifies the address bar
scrollbarsspecifies scrollbars
statusspecifies the status bar
resizespecifies whether the window can be resized by the user

Assigning a feature the value 1 provides the feature. Assigning a feature the value 0 prevents the feature. The example below creates a window with a menu bar and address bar, but no tool bar. Note that the feature specifications are separated by commas, and you can put them in any order.

<script language="JavaScript">
var myPopUp = window.open("mypage.htm", "pop_window", "menubar=1, location=1, toolbar=0"); </script>

What happens if you omit the specification of a feature? That depends on the browser version used to view the page. In some browsers, features not specified appear by default. In some browsers features not specified are not provided by default. To get reliable results, you should always specify all the features.

If you like to reuse code, you can specify the features list in a string variable and then use that variable name as the features list argument in the window.open function. This will prevent you from having to memorize the features list.

<script language="JavaScript">
var features = "left=100, top=100, width=256, height=256, menubar=1, toolbar=0, location=0, scrollbars=0, status=0"; var myPopUp = window.open("mypage.htm", "pop_window",features); </script>

RSS Feed RSS Feed



Web Design Sections

Eloquent JavaScript: A Modern Introduction to Programming

Eloquent JavaScript

Eloquent JavaScript Eloquent JavaScript goes beyond the cut-and-paste scripts of the recipe books and teaches you to write code that's elegant and effective. You'll start with the basics of programming, and learn to use variables, control structures, functions, and data structures. Then you'll dive into the real JavaScript artistry: higher-order functions, closures, and object-oriented programming.

Reader Anthony says, "This book is not your typical Javascript book. Others have a utilitarian approach. In stark contrast, Eloquent JavaScript does not merely provide you a checklist of things to learn but rather paints a panorama of the possibilities that programming provides. Javascript is merely the tool used to introduce these to the reader.

Click here for more information.


[Site User Agreement] [Advertise on This site] [Search This Site] [Contact Form]
Copyright©2001-2011 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268