Skip to main content

Window moveBy() Method in JAVA SCRIPT

Definition and Usage..
The moveBy() method moves a window a specified number of pixels relative to its current coordinates.
Return Value: No return value
Syntax : window.moveBy(x, y)
Differents way how to declare moveBy() Method in program.
CODING:
<!DOCTYPE html>
<html>
<body>
<p>Open "NewWindow" and move the new window to the top left corner of the screen:</p>
<button onclick="openW()">New window</button>
<button onclick="moveTo()">Move window</button>
<script>
var newWindow;
function openW() {
    newWindow = window.open("", "", "width=250, height=250");
    newWindow.document.write("<p>This is newWindow click move button and move the newWindow.</p>");
    newWindow.moveBy(50, 50);
}
function moveTo() {
    newWindow.moveBy(50, 50);
    newWindow.focus();
}
</script>
</body>
</html>

Comments