i have the problem that IE cant bring up opener window when i call opener.focus() method
window.opener.focus(); // After that, child window stay in front.
html1.htm file:
<script type="text/javascript" language="JavaScript"><!--
function toCompare() {
wCompare = window.open("html2.htm", "wCompare", "width=800,height=600,resizable=yes,directories=no,status=no,toolbar=no,menubar=0,location=no,scrollbars=yes");
wCompare.focus();
};
//--></script>
</head>
<body>
<a href="javascript://" onClick="toCompare();">open child window</a>
</body>
html2.htm
<script type="text/javascript" language="JavaScript"><!--
function show_Parent(url) {
window.opener.location.href = url;
window.opener.focus(); // After that, child window stay in front.
}
//--></script>
</head>
<body>
<a onclick="return show_Parent('html3.htm');">go back to parent window</a>
</body>
i have the problem that IE cant bring up opener window when i call opener.focus() method
window.opener.focus(); // After that, child window stay in front.
html1.htm file:
<script type="text/javascript" language="JavaScript"><!--
function toCompare() {
wCompare = window.open("html2.htm", "wCompare", "width=800,height=600,resizable=yes,directories=no,status=no,toolbar=no,menubar=0,location=no,scrollbars=yes");
wCompare.focus();
};
//--></script>
</head>
<body>
<a href="javascript://" onClick="toCompare();">open child window</a>
</body>
html2.htm
<script type="text/javascript" language="JavaScript"><!--
function show_Parent(url) {
window.opener.location.href = url;
window.opener.focus(); // After that, child window stay in front.
}
//--></script>
</head>
<body>
<a onclick="return show_Parent('html3.htm');">go back to parent window</a>
</body>
Share
Improve this question
edited Oct 20, 2009 at 18:41
Ishmael
32.7k4 gold badges40 silver badges49 bronze badges
asked May 18, 2009 at 7:05
GnosisGnosis
2 Answers
Reset to default 2This works fine for me, but I have seen similar behavior. Try creating a function in the parent page that grabs it's own focus and changes the URL
html1.htm
function focusAndGo(url) {
window.focus();
// EDIT: changed document.location.href= to window.location.href=
// Reference:
// https://developer.mozilla/En/Document.location
// document.location was originally a read-only property,
// although Gecko browsers allow you to assign to it as well.
// For cross-browser safety, use window.location instead.
window.location.href=url;
}
and call this from html2.htm
window.opener.focusAndGo(url);
Try to blur the current window first, maybe that helps.
window.blur();
window.opener.focus();
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744839818a4596488.html
评论列表(0条)