ボタンをクリックすると新しいウインドウが開きます。


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>ドキュメントを書き出したい</title>
<script type="text/JavaScript">
<!--
function new_win(){
var win1;
win1 = window.open("","new_document1");
win1.document.open();
win1.document.writeln("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>");
win1.document.writeln("<html><head><title>新しいウインドウです。</title>");
win1.document.writeln("<meta http-equiv='Content-Script-Type' content='text/javascript'></head>");
win1.document.writeln("<body>");
win1.document.writeln("<p>新しいウインドウに文字列を書き込みます。</p>");
win1.document.writeln("<p>もちろんイメージもOKです<br>");
win1.document.writeln("<img src='images/img01.gif' alt='私!?' width='200' height='160'></p>");
win1.document.writeln("<form><input type='button' value='ウインドウを閉じる' onClick='window.close()'></form>");
win1.document.write("</body></html>");
win1.document.close();
}
// -->
</script>
</head>
<body>
<p>ボタンをクリックすると新しいウインドウが開きます。</p>
<form><input type="button" value="ウインドウを開く" onClick="new_win()"></form>
</body>
</html>


★解説★