window.open
親ウィンドウから子ウィンドウを開くために使用しています。ユーザーが親ウィンドウにエントリを作成しているときに子ウィンドウを参照できるように、子ウィンドウを一番上に置いておきたい。これはできますか?私は現在 Firefox を使用していますが、すべてのブラウザーで動作するようになればボーナスです。
36500 次
6 に答える
4
新しいウィンドウを開く代わりにpopup divを使用するのはどうですか?
于 2012-12-20T05:46:50.053 に答える
4
このポップアップレイヤーも良いです: DOMWindowDemo。
于 2012-12-20T05:09:52.787 に答える
0
はい、子ウィンドウの本文にonBlur = "self.focus()"を指定したこのコードでこれを行うことができます
//Parent page...
<html>
<body>
<a href="#" onClick="window.open('two.html','sdvwsv','width=200,height=200');">here...</a>
</body>
</html>
//Child page...
<html>
<body onBlur="self.focus();">
here...
</body>
</html>
于 2012-12-20T05:14:58.913 に答える
0
<html>
<script language="JavaScript">
<!--
function openWin(){
var myBars = 'directories=no,location=no,menubar=no,status=no';
myBars += ',titlebar=no,toolbar=no';
var myOptions = 'scrollbars=no,width=400,height=200,resizeable=no,top=10, left=10,';
var myFeatures = myBars + ',' + myOptions;
var myReadme = 'This is a test.'
var newWin = open('', 'myDoc', myFeatures);
newWin.document.writeln('<form>');
newWin.document.writeln('<table>');
newWin.document.writeln('<tr valign=TOP><td>');
newWin.document.writeln('<textarea cols=45 rows=7 wrap=SOFT>');
newWin.document.writeln(myReadme + '</textarea>');
newWin.document.writeln('</td></tr>');
newWin.document.writeln('<tr><td>');
newWin.document.writeln('<input type=BUTTON value="Close"');
newWin.document.writeln(' onClick="window.close()">');
newWin.document.writeln('</td></tr>');
newWin.document.writeln('</table></form>');
newWin.document.close();
newWin.focus();
}
-->
</script>
<body>
<form>
<b>Click the following button to open a new window: </b>
<input type=BUTTON value="Open" onClick='openWin()'>
</form>
</body>
于 2012-12-20T05:18:18.483 に答える
0
私は長い間これと格闘しました。FFのバグのようですが、新しいウィンドウが開いた後にクリックすると、フォーカスが当たって一番上に来ることに気付きました。ただし、 window.focus() の呼び出しは機能しなかったため、早すぎると思いました。
したがって、新しいウィンドウ コードでは、追加したページの下部に
setTimeout(function(){window.focus()},100);
堅実な練習のようには感じませんが、それが機能する必要がある場合... 100mSec は、私のシステムで機能する最低値のようです。
于 2013-12-13T18:40:07.583 に答える
-1
<html>
<script language="JavaScript">
<!--
function openWin(){
var myBars = 'directories=no,location=no,menubar=no,status=no';
myBars += ',titlebar=no,toolbar=no';
var myOptions = 'scrollbars=no,width=600,height=400,resizeable=no,top=10, left=10';
var myFeatures = myBars + ',' + myOptions;
var newWin = open('test.html', '', myFeatures);
newWin.document.close();
newWin.focus();
}
-->
</script>
<body>
<form>
<b>Click the following button to open a new window: </b>
<input type=BUTTON value="Open" onClick='openWin()'>
</form>
</body>
</html>
</html>
于 2012-12-20T05:24:05.930 に答える