PHP & JavaScript Room :: 設置サンプル

実行結果

画像をクリックすると拡大画像を別ウィンドウに表示

ソース

<script type="text/javascript">
    function JustSizeWindow(img,width,height){
        /* ウィンドウを開く位置、ウィンドウサイズを指定 */
        var opt = "";
        opt+='top=0,left=0';
        opt+=',width='+width+',height='+height+',';
        opt+='directories=0,toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0';
        /* 新ウィンドウを開く */
        jsw=window.open('','jsw',opt);
        /* 新ウィンドウにフォーカスを当てる */
        jsw.focus();
        /* 新ウィンドウにドキュメントを書出 */
        jsw.document.open();
        htm  = '<html><head>';
        htm+='<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
        htm+='<title>画像サンプル<\/title>';
        htm+='<\/head>';
        /* body要素の余白をゼロに指定 */
        htm+='<bod' + 'y style="margin:0; padding:0;">';
        /* 画像をクリックすると、ウィンドウを閉じるようにする */
        htm+='<a href="javascript:window.close();">';
        htm+='<img src="'+img+'" width="'+width+'" height="'+height+'" border="0" alt="画像をクリックするとウィンドウを閉じます">';
        htm+='<\/a>';
        htm+='<\/bod'+'y><\/html>';
        jsw.document.write(htm);
        jsw.document.close();
    }
</script>

<!-- 画像をクリックすると拡大画像を別ウィンドウに表示する -->
<a href="javascript:JustSizeWindow('/content/img/pic1.png',320,240)"><img src="/content/img/pic1-thumb.png" width="120" height="90" border="0" alt="画像をクリックすると拡大画像を別ウィンドウに表示" /></a>

polarized women