3

HTMLコーディングの初心者ですが、ウィンドウサイズやその他のプロパティをページに直接書き込むことができるかどうか疑問に思っていました。Ilは説明します。

計算に取り組んでいて、デスクトップでhtmlファイルを実行したいと思います。すべて正常に動作しますが、他のタブが開いているブラウザで起動します。固定ウィンドウサイズのステータスバーブックマークバーのない小さなポップアップウィンドウで実行したい。

編集:

コード自体

<!doctype html>
<html>
<head><center>Kalkuraatur</center>
<Title>Javascripti Kalkulaator</title>
<script type="text/javascript">
    if(window.name != "mypopup") {
        window.open(document.location.href,'mypopup', 'left=300,top=200,width=200,height=200,toolbar=0,status=0,location=0,menubar=0,scrollbars=0,titlebar=0'); var child = window.open(...; child.focus();
        window.close();
    }
</script>
<script type="text/javascript">
function arvuta ()
{
kalku.sisend.value = eval(kalku.sisend.value)
}
function Bspace(sisend)
{
kalku.sisend.value = kalku.sisend.value.substring(0, kalku.sisend.value.length - 1)
}
</script>
</head>
<body>
<center>
<form name="kalku">
<table border=2>
<tr><td>
<input type="text" name="sisend" size="21">
<br>
</td></tr>
<tr><td>
<input type="button" name="seitse" value=" 7 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '7'">
<input type="button" name="kaheksa" value=" 8 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '8'">
<input type="button" name="yheksa" value=" 9 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '9'">
<input type="button" name="ykstagasi" value="del" style="height: 22px; width: 30px" onclick="Bspace(this)">
<input type="button" name="kustuta" value=" C " style="height: 22px; width: 30px" onclick="kalku.sisend.value = ''">
<br>
<input type="button" name="neli" value=" 4 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '4'">
<input type="button" name="viis" value=" 5 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '5'">
<input type="button" name="kuus" value=" 6 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '6'">
<input type="button" name="jaga" value=" ÷ " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '/'">
<input type="button" name="korruta" value=" x " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '*'">
<br>
<input type="button" name="yks" value=" 1 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '1'">
<input type="button" name="kaks" value=" 2 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '2'">
<input type="button" name="kolm" value=" 3 " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '3'">
<input type="button" name="lahuta" value=" - " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '-'">
<input type="button" name="plus" value=" + " style="height: 22px; width: 30px" onclick="kalku.sisend.value += '+'">
<br>
<input type="button" name="null" value=" 0 " style="height: 23px; width: 64px" onclick="kalku.sisend.value += '0'">
<input type="button" name="koma" value=" , " style="height: 22px; width: 30px" onclick="kalku.sisend.value += ','">
<input type="button" name="v6rdub" value=" = " style="height: 22px; width: 64px" onclick="arvuta ()">
</td></tr>
</form>
</center>
</body>
</html>
4

3 に答える 3

1

ポップアップブロッカーを設定/処理する場合は、これをhtmlドキュメントの先頭への最初のエントリとして追加できます。

<script type="text/javascript">
    if(window.name != "mypopup") {
        window.open(document.location.href,'mypopup', 'left=300,top=200,width=200,height=200,toolbar=0,status=0,location=0,menubar=0,scrollbars=0,titlebar=0');
        window.open('', '_self', ''); // chrome bug
        window.close();
    }
</script>

テストはしていませんが、フォーカスのためにこれを試してください:

<script type="text/javascript">
    if(window.name != "mypopup") {
        var childWindow = window.open(document.location.href,'mypopup', 'left=300,top=200,width=200,height=200,toolbar=0,status=0,location=0,menubar=0,scrollbars=0,titlebar=0');
        //like this
        childWindow.focus();
        window.open('', '_self', ''); // chrome bug
        window.close();
    } else {
        //or like this
        window.focus();
    }
</script>
于 2012-10-18T18:56:34.837 に答える
0

私の知る限り、ブラウザウィンドウのサイズはHTMLでは変更できません。javascriptこれで、および/またはを使用して独自のポップアップを作成できますjQuery

ユーザーが表示されるページに「クリックして計算を実行」リンクを追加します。リンクをクリックすると、カスタムポップアップが起動します。

これが私の言いたいことの実例です。

于 2012-10-18T18:43:37.853 に答える
0

W3のwindow.openドキュメントを見て、必要なものを指定してください。

http://www.w3schools.com/jsref/met_win_open.asp

于 2012-10-18T18:59:13.187 に答える