Skip to content

Instantly share code, notes, and snippets.

@h4
Created April 2, 2012 19:52
Show Gist options
  • Select an option

  • Save h4/2286767 to your computer and use it in GitHub Desktop.

Select an option

Save h4/2286767 to your computer and use it in GitHub Desktop.
Объект window
function openWin() {
myWindow = window.open("", "", "width=200,height=100");
myWindow.document.write("Вот оно - 'myWindow'!");
myWindow.focus();
myWindow.opener.document.write("Это окно, из которого открыли новое окно");
}
<html>
<head>
<script type="text/javascript">
function openWin() {
myWindow=window.open("","","width=200,height=100");
myWindow.document.write("<p>Это окно - 'myWindow'</p>");
}
function closeWin() {
myWindow.close();
}
function checkWin() {
if (myWindow.closed) {
document.getElementById("msg").innerHTML="'myWindow' закрыто!";
} else {
document.getElementById("msg").innerHTML="'myWindow' не закрыто!";
}
}
</script>
</head>
<body>
<input type="button" value="Открыть 'myWindow'" onclick="openWin()" />
<input type="button" value="Закрыть 'myWindow'" onclick="closeWin()" />
<br />
<input type="button" value="Окно 'myWindow' закрыто?" onclick="checkWin()" />
<br />
<div id="msg"></div>
</body>
</html>
function moveWin() {
myWindow.moveBy(250,250);
myWindow.focus();
}
function resizeWindow() {
myWindow.resizeTo(500,300);
}
function open_win() {
window.open("http://www.w3schools.com","_blank","toolbar=yes, location=yes, directories=no,status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400,height=400");
}
<head>
<title>открыть окно</title>
<script type="text/javascript">
function openWin() {
myWin= open("", "displayWindow", "width=500,height=400,status=yes,toolbar=yes,menubar=yes");
myWin.document.open();
myWin.document.write("<html><head><title>на_лету</title></head><body>");
myWin.document.write("<font size=+3>");
myWin.document.write("Этот HTML-документ был создан с помощью JavaScript!");
myWin.document.write("</font></body></html>");
myWin.document.close();
}
</script>
</head>
<body>
<form>
<input type="button" value="создай страницу на лету!" onclick="openWin();">
</form>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment