Moving Windows
moveBy ( ) – This method moves the current window by a specified amount of pixels.
Syntax:- window.moveBy(horizontalPixels, verticalPixels);
Where,
window – It is the name of the window to move or is called just window if it is the main window.
horizontalPixels – It is the number of horizontal pixels to move the window where positive numbers move the window to the right and negative numbers to the left.
verticalPixels – It is the number of vertical pixels to move the window where positive number move the window down and negative number up.
Ex:- newWindow.moveBy(200, 200);
Moving Windows
moveTo ( ) – This method moves the window to the specified coordinates.
Syntax:- window.moveTo(x, y);
Where,
window – It is the name of the window to move or is called just window if it is the main window.
x – It is the screen co-ordinate on the x-axis to move the window to.
y – It is the screen co-ordinate on the y-axis to move the window to.
Ex:- newWindow.moveTo(200, 200);
Resizing Windows
Resizing Windows
resizeBy ( ) – This method is used to resize the current window by a certain amount, relative to its current size.
Syntax:- window.resizeBy(width, height);
Where,
window – It is the name of the window to move or is called just window if it is the main window.
width – It is the number of width pixels, where positive numbers increase the window and negative numbers decrease.
height – It is the number of height pixels, where positive numbers increase the window and negative numbers decrease.
Ex:- newWindow.resizeBy(200, 200);
Resizing Windows
resizeTo ( ) – This method is used to resize a window to the specified width and height.
Syntax:- window.resizeTo(width, height);
Where,
window – It is the name of the window to move or is called just window if it is the main window.
width – It is an integer representing the new outerWidth in pixels (including scroll bars, title bars, etc).
height – It is an integer value representing the new outerHeight in pixels (including scroll bars, title bars, etc).
Ex:- newWindow.resizeTo(200, 200);
Scrolling Windows
scrollBy ( ) – This method scrolls the document in the window by the given amount.
Syntax:- window.scrollBy(x, y); or window.scrollBy(options);
Where,
window – It is the name of the window to scroll or is called just window if it is the main window.
x – How many pixels to scroll by, along the x-axis (horizontal). Positive values will scroll to the right, while negative values will scroll to the left
y – How many pixels to scroll by, along the y-axis (vertical). Positive values will scroll down, while negative values scroll up
Options – It is an object with three possible properties:
top, which is the same as the y-coord
left, which is the same as the x-coord
behavior, which is a string containing one of smooth, instant, or auto; default is auto
Note – For this method to work, the visible property of the window’s scrollbar must be set to true!
Scrolling Windows
scrollTo ( ) – This method scrolls to a particular set of coordinates in the document.
Syntax:- window.scrollTo(x, y); or window.scrollTo(options);
Where,
window – It is the name of the window to scroll or is called just window if it is the main window.
x – It is the pixel along the horizontal axis of the document that you want to be displayed in the upper left.
y – It is the pixel along the vertical axis of the document that you want to be displayed in the upper left.
options is an object with three possible properties:
top, which is the same as the y-coord
left, which is the same as the x-coord
behavior, which is a string containing either smooth, instant, or auto; default is auto