Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function split() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 101

Deprecated: Function eregi_replace() is deprecated in /home3/vvaswani/sql.php on line 301

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 107

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 109

Deprecated: Function ereg_replace() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 124

Deprecated: Function ereg_replace() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 125

Deprecated: Function split() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 127

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174
The Melonfire Community - Trog
Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
Controlling Browser Properties With JavaScript
Get to grips with the Window, Location and History objects.

| Moving Windows |

You might not know this, but the alert() function you call every time you want a pop-up on your page is actually a method of the Window object. Take a look:


<script language="JavaScript">
// pop up alert
window.alert("I can see you");
</script>


There's also a window.confirm() method, which displays a confirmation box with a message and two buttons. Depending on the button you pick, the method returns true or false. Take a look at the next example, which demonstrates:


<script language="JavaScript">
// ask a question
var answer = window.confirm("Parlez-vous Francais?");

// process the response
if (answer) { window.alert ("Tres bon, comment allez-vous?"); } else { window.alert ("Illiterate pig!"); }
</script>


Finally, the window.prompt() method pops up an input box and stores the user's input in a variable. The following example illustrates:


<script language="JavaScript">
// ask for user input
var name = window.prompt("Enter your screen name");

// print it back
window.alert ("Welcome, " + name);
</script>


You can move a window to the front of the window stack by calling the window.focus() method (remember to use the window name when calling this method, or you won't see anything special happen), and the window.blur() method to move a window to the back of the stack. Consider the following example, which creates a child window and then allows you to move it to the front and back of the window stack using these methods:


<html>
<head>
</head>
<script language="JavaScript">
var newWin = window.open("windows.html", "newWin");
</script>
<body>

<a href="javascript:newWin.blur();">Move child window back</a>
<br>
<a href="javascript:newWin.focus();">Move child window front</a>

</body>
</html>


You can resize a window by calling the window's resizeTo() method, as in the example below:


<html>
<head>
</head>
<body>

<a href="javascript:var test = window.open('', 'test');"><b>Open test window</b></a>

<p>

<b>Resize test window</b> to:

<ul>
<li><a href="javascript: test.resizeTo(300, 300);">300 x 300</a>
<li><a href="javascript: test.resizeTo(640, 480);">640 x 480</a>
<li><a href="javascript: test.resizeTo(800, 600);">800 x 600</a>
</ul>

<a href="javascript:test.close();"><b>Close test window</b></a>

</body>
</html>


Consider the following example, which allows you to input height and width values into a form, and uses these values to adjust the target window's height and width appropriately:


<html>
<head>
<script language="JavaScript">
var test = window.open('', 'test');
function changeSize()
{
   var width=document.forms[0].winwidth.value;
   var height=document.forms[0].winheight.value;
   test.resizeTo(parseInt(width), parseInt(height));
}
</script>
</head>
<body>

<form>
Width
<input type="text" size="3" name="winwidth">

Height
<input type="text" size="3" name="winheight">

<input type="button" onClick="javascript:changeSize()" value="Change Window Size">
</form>

</body>
</html>



How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!


previous page more like this  print this article  next page
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-
Strict Standards: mktime(): You should be using the time() function instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 731
2018 Melonfire. All rights reserved
Terms and Conditions | Feedback