Home >Web Front-end >JS Tutorial >JavaScript method to pop up a new window and control the window to move to a specified position_javascript skills

JavaScript method to pop up a new window and control the window to move to a specified position_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:05:432089browse

The example in this article describes how to use JavaScript to pop up a new window and control the window to move to a specified position. Share it with everyone for your reference. The details are as follows:

The following JS code pops up a new window through window.open, and then controls the window to move to the specified position through the JS code

<!DOCTYPE html>
<html>
<head>
<script>
function openWin()
{
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>This is 'myWindow'</p>");
}
function moveWin()
{
myWindow.moveTo(0,0);
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="Open 'myWindow'" 
onclick="openWin()" />
<br><br>
<input type="button" value="Move 'myWindow'" 
onclick="moveWin()" />
</body>
</html>

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn