JavaScript
  Home arrow JavaScript arrow Page 2 - Start Working With Browser Windows in Java...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Start Working With Browser Windows in JavaScript
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2006-04-18

    Table of Contents:
  • Start Working With Browser Windows in JavaScript
  • How to move the current browser window using JavaScript
  • How to maximize the current browser window using JavaScript
  • How to open a new pop up window using JavaScript
  • A word of caution

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Start Working With Browser Windows in JavaScript - How to move the current browser window using JavaScript


    (Page 2 of 5 )

    Now, let us try to develop a simple script (JavaScript) to move the current browser window.  Have a look at the following code:

    <html>
          <head>
                <meta  name=vs_targetSchema
     content="http://schemas.microsoft.com/intellisense/ie5">
    <script  id="clientEventHandlersJS"  language="javascript">
    <!--
    function Apply(x,y)
    {
          window.moveTo(x,y); 
          //window.moveBy(x,y);
    }

    function ButtonMove_onclick() {
          var x = document.all("txtX").value;
          var y = document.all("txtY").value;
          Apply(x,y);
    }
    //-->
                </script>
          </head>
          <body>
                <form  id="form1">
                      Enter X:<input  type="text"  id="txtX"  NAME="txtX"
     value="100"><br>
                      Enter Y:<input  type="text"  id="txtY"  NAME="txtY"
     value="200"><br>
                      <input  type="button"  value="Show"  id="ButtonMove"
     name="ButtonMove"  onclick="return ButtonMove_onclick()">
                </form>
          </body>
    </html>

    Within the above code, I managed to create two textboxes named “txtX” and “txtY” and a button named “ButtonMove.”  When the button (buttonMove) is clicked, the control goes to the function “ButtonMove_onclick.”  This function mainly captures the values (X and Y) given by the user and finally calls another function, “Apply” (along with passing those values).

    The function “Apply” mainly contains the following statement:

          window.moveTo(x,y);

    The “window” is a built-in object in JavaScript which contains a method, “moveTo.”  The method accepts two parameters, left and top (or x and y).  The method automatically moves the window to the specified left and top values provided.  The above statement moves the current browser window (on which your web page is displayed) to the left and top values you specified within the textboxes.  Let us consider another alternative:

          window.moveBy(w,h); 

    This is very similar to what I explained in the previous section.

    More JavaScript Articles
    More By Jagadish Chaterjee


       · Hello beginners! you may find this contribution bit worth, when you wanted to...
       · Hi to all, I m a s/w programmer woking on java/jsp on tomcat.I tried the...
     

    JAVASCRIPT ARTICLES

    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in
    - Active Client Pages at the Server
    - ACP Tab Web Page







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT