web技 |
◆手順1【スクリプト】
※<head>〜</head>に記述します
※サンプルは新たにhtmlファイルを作っています([技k009]参照)
-----次の行から(copy)-----
<script type="text/javascript">
<!--
function winOpen(FILE) {
var WINWIDTH; //画像の幅
var WINHEIGHT; //画像の高さ
var subWin;
subWin=window.open("","SUB_WIN_k010",
"top=100,left=50,scrollbars=0,resizable=1,toolbar=0,menubar=0,location=0,directories=0,status=0");
//ウィンドウを開く
subWin.document.open(); //ドキュメントストリームを開く
subWin.document.write("<html><head>"); //以下にドキュメントを書き出す
subWin.document.write("<title>サンプル</title>");
subWin.document.write("<style type='text/css'> body { font-family: MS Pゴシック; font-size:11pt; background-color:#000000; color:#ffffff;} </style></head>");
subWin.document.write("<body onBlur='focus()'>");
subWin.document.write("<div style='top:20px; left:20px; position:absolute;'>
" +"<a href='JavaScript:window.close()' title='Windowを閉じる'>Windowを閉じる</a><br><br>");
subWin.document.write("<img src='" + FILE + "' name='PIC'
border='1'></div>");
subWin.document.write("</body></html>");
subWin.document.close(); //ドキュメントストリームを閉じる
WINWIDTH=subWin.document.PIC.width+50; //ウィンドウの幅(画像幅+余白
WINHEIGHT=subWin.document.PIC.height+100; //ウィンドウの高さ(画像高さ幅+余白
subWin.resizeTo(WINWIDTH,WINHEIGHT); //ウィンドウのサイズ変更
}
//-->
</script>
-----上の行まで(copy)-----
◆手順2【リンク文字からの実行】
※<body〜</body>に記述します
※オープンする画像の相対パスを指定してスクリプトを実行します
-----次の行から(copy)-----
<a href="javascript:winOpen('photo/w600.JPG')">画像(600W)</a>
-----上の行まで(copy)-----
|