WebBuilder101 - Making the web happen!
Need Web Dev software? Here is the place to
Flash Point
Creating/Opening new windows with JavaScript


Web Builders usually create/open new windows to show users additional information without losing the information that they are reading. Although you can easily open new windows with HTML, using JavaScript to do the job gives you more control over the look and feel of the new window you want to create/open. Let's go ahead and find out how to create/open a new window using JavaScript.

The HTML way

<a href="http://www.your_domain.com/your_webpage.html" target="_blank">

As you can see, creating/opening a new window with HTML is extremely easy. All you are doing is create a link to a web page that loads in a new window - the code that opens the new window is target="_blank".

See it work

The JavaScript way (my comments are in red and do not have to be included in the script)

<script language=javascript>
Since this is a script, you need the opening and closing <script></script> statements
<!--Hide script from older browsers
function newWindow() {
myWindow = window.open ('example.html', 'myWindow', 'width=300, height=200, toolbar=no, location=no, scrollbar=no')
This is the code responsible for opening the new window - attributes such as "width, toolbar" set the new window's appearance
}
//End hiding script from older browsers-->
</script>

Add this part somewhere in the BODY

<a href="javascript:newWindow()">See it work</a>
This will help you trigger the effect - that is open the new window

See it work

Closing the window

To close the window all you have to do is add the following code to the "new" (the page that is being opened with the script) page.

<a href="JavaScript: parent.window.close() ;">See it work</a>

There are many other ways you can create/open a new window with JavaScript, however the example above is one of the easiest ways to do it.

.

 

More Resources
Scrolling Text
Taking and pasting input to your web page
Customize Messages
Create Rollovers
Change Background colors
Put the current date on your site

Suggested Reading

Beginning Active Server Pages 3.0
JavaScript Bible
Red Hat Linux
Dreamweaver 3.0
HTML Bible



Download WB101 Wallpaper
• Web Builder 101 Wallpaper Get it!.
• Find out how to create your own Wallpaper Teach me!.
Sign up for our Newsletters
• Web Building Sign me Up!.
• Net Alert! Sign me Up!.
Need Help?
• Contact Support Click here.
• E-mail the Webmaster Click Here.
• Search Tips Click Here.

Webbuilder101.com © 1998 - 2003 Copyright and Terms of Use
Send mail to: webmaster@webbuilder101.com

» About » Support

» FAQ » What's New » MyLog

Web Builder 101 Web Builder 101 - Making the Web Happen Web Builder 101 - Making the Web Happen
.