Friday, August 31, 2012

JavaScript Browser Objects Examples


Examples of using JavaScript to access and manipulate the Browser objects.

Window Object

Display an alert box
Display an alert box with line-breaks
Display a confirm box, and alert what the visitor clicked
Display a prompt box
Create a pop-up window Open a new window when clicking on a button
Open a new window and control its appearance
Open multiple new windows
Assure that the new window does NOT get focus (send it to the background)
Assure that the new window GETS focus
Close the new window
Checks whether the new window has been closed or not
Return the name of the new window
Write some text to the source (parent) window
Move the new window relative to its current position
Move the new window to the specified position
Print the current page
Resize a window by the specified pixels
Resize a window to a specified size
Scroll the content by the specified number of pixels
Scroll the content to a specified position
A simple timing
Set and stop a timer with setTimeout() and clearTimeout()
Set and stop a timer with setInterval() and clearInterval()
More Window object examples in our JavaScript reference.

Navigator Object

More Navigator object examples in our JavaScript reference.

Screen Object

More Screen object examples in our JavaScript reference.

History Object

More History object examples in our JavaScript reference.

Location Object

More Location object examples in our JavaScript reference.

JavaScript Objects Examples


Examples of using the built-in JavaScript objects.

String Object

More String object examples in our JavaScript reference.

Date Object

More Date object examples in our JavaScript reference.

Array Object

More Array object examples in our JavaScript reference.

Boolean Object

More Boolean object examples in our JavaScript reference.

Math Object

General

More Math object examples in our JavaScript reference.

JavaScript Examples


Basic JavaScript Examples


JavaScript Statements, Comments and Blocks


JavaScript Variables


JavaScript Conditional If ... Else


JavaScript Popup Boxes


JavaScript Functions


JavaScript Loops


JavaScript Events


JavaScript Error Handling


Advanced JavaScript Examples


Have You Learned JavaScript?


JavaScript Summary

This tutorial has taught you how to add JavaScript to your HTML pages, to make your web site more dynamic and interactive.

You have learned how to create responses to events, validate forms and how to make different scripts run in response to different scenarios.

You have also learned how to create and use objects, and how to use JavaScript's built-in objects.
For more information on JavaScript, please look at our JavaScript examples and our JavaScript reference.

Now You Know JavaScript, What's Next?

The next step is to learn about the HTML DOM, jQuery, and AJAX.
If you want to learn about server-side scripting, the next step is to learn ASP or PHP.

HTML DOM
The HTML DOM defines a standard way for accessing and manipulating HTML documents.
The HTML DOM is platform and language independent and can be used by any programming language like Java, JavaScript, and VBScript.

If you want to learn more about the DOM, please visit our HTML DOM tutorial.

jQuery
jQuery is a JavaScript Library.
jQuery greatly simplifies JavaScript programming.

If you want to learn more about jQuery, please visit our jQuery tutorial.

AJAX
AJAX = Asynchronous JavaScript and XML.
AJAX is not a new programming language, but a new way to use existing standards.
AJAX is about exchanging data with a server, and update parts of a web page - without reloading the whole page.

Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook tabs.
If you want to learn more about AJAX, please visit our AJAX tutorial.

ASP / PHP
While scripts in an HTML file are executed on the client (in the browser), scripts in an ASP/PHP file are executed on the server.

With ASP/PHP you can dynamically edit, change or add any content of a Web page, respond to data submitted from HTML forms, access any data or databases and return the results to a browser, customize a Web page to make it more useful for individual users.

Since ASP/PHP files are returned as plain HTML, they can be viewed in any browser.

If you want to learn more about ASP, please visit our ASP tutorial.
If you want to learn more about PHP, please visit our PHP tutorial.