Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 16:05:43
Original
2034 people have browsed it

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>
Copy after login

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!