あなたのご意見をお寄せいただき、ありがとうございました。
私は、以下の方法で問題を解決した:
を次のJavaScriptは、新しいウィンドウを開くために使用される新しいウィンドウにホームページから移動するとき:
function popupFull(url)
// For explanation of this code see: http://www.quirksmode.org/js/popup.html
// Note: If fullscreen = 1 you can't see the menubar, toolbar, status etc.
// It is advisable to have no spaces around the commas in the parameters.
{
//alert("Opening: " + url)
// Prepare the parameter string
params = 'width='+screen.width;
params += ',height='+screen.height;
params += ',top=0,left=0';
params += ',fullscreen=0';
params += ',menubar=0';
params += ',toolbar=0';
params += ',directories=0';
params += ',status=0';
params += ',scrollbars=0';
params += ',resizable=1';
// Open a new window.
newWin=window.open(url, "fullWindow", params);
// If the current Window is in focus, switch focus to the new Window.
if (window.focus)
{
newWin.focus()
}
// Return the new Window object reference.
return newWin;
}
ので、新しいウィンドウをすることができ私はHomepage Windowを開いたままにしておきましたが、新しいWindowの背後にはフォーカスがありません。
新しいウィンドウには「メニュー」ボタンがあります。これをクリックすると、次のJavaScript関数を呼び出します。
function openMenu(winURL, winName, winFeatures)
{
// Create a reference of the Window which opened this Window. This should be
// the Main Menu Window.
var winObj=window.opener;
var menuOuterWidth = 1080;
var menuOuterHeight = 896;
var menuInnerWidth = 1068;
var menuInnerHeight = 767;
var menuX = (screen.width - menuOuterWidth)/2;
var menuY = (screen.height - menuOuterHeight)/2;
// Prepare the parameter string for re-opening the Menu
params = 'width='+menuInnerWidth;
params += ',height='+menuInnerHeight;
params += ',top='+menuY+',left='+menuX;
params += ',fullscreen=0';
params += ',menubar=1';
params += ',toolbar=1';
params += ',status=1';
params += ',scrollbars=1';
params += ',location=1';
params += ',resizable=1';
try
{
// Check to see if the window reference already exists.
if (winObj)
{
// Check to see if the Menu window is closed.
if (winObj.closed)
{
// The Menu window is closed.
// Open the Menu Window.
winObj = window.open(winURL, winName, params);
// Close this Course Window.
window.close();
// Return the Menu Window object reference should the caller want it.
return winObj;
}
else
{
// The Menu Window has not been closed. Set the Window's size and position.
// Note: When resizing the outerWidth/outerHeight value has to be passed.
winObj.window.resizeTo(menuOuterWidth, menuOuterHeight);
winObj.window.moveTo(menuX, menuY);
// Bring it into focus (bring to front).
winObj.focus();
// Close this Course Window.
window.close();
// Return the Menu Window object reference should the caller want it.
return winObj;
}
}
else
{
// The winObj object does not exist. Open the Menu.
winObj = window.open(winURL, winName, params);
// Close this Course Window.
window.close();
// Return the Menu Window object reference should the caller want it.
return winObj;
}
}
catch(err)
{
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.description + "\n\n";
txt+="Click OK to continue.\n\n";
//alert(txt);
// When IE6 tries to obtain the winObj.closed property, when the window is closed, it can cause
// an error "Permission Denied". This error is caught here. Open the Menu.
// Open the Menu Window.
winObj = window.open(winURL, winName, params);
// Close this Course Window.
window.close();
// Return the Menu Window object reference should the caller want it.
return winObj;
}
}
コメントがすべてを説明する必要があります。キーは、開始したHomepage Windowへの参照を取得することです。 (var winObj=window.opener;
)。
私は新しいウィンドウを開くと(IE6を使用して)ホームページに戻り、ホームページウィンドウを閉じた後、[メニュー]ボタンをクリックした新しいウィンドウで何も起こりませんでした。私はすべてを試した後、一杯のお茶の後に、私がエラーキャプチャの形式を使わずに開発していたアプリケーションにコードを書くことは決してないと気づきました。 Try、Catch文を追加し、エラーを「警告」に報告しました。 「Permission Denied」エラーが表示されます。
多くの読書の後、私はエラーを取り除くことができなかったと思ったので、私はできるだけエレガントにエラーを処理します。これで上記のコードが作成されました。
これは治療に役立ち、これが誰かを助けることを願っています。
すべての種類のウィンドウを開くUIはあまり親切ではありません。異なるデザインを検討してください。 – Oded
ウィンドウ名を追跡するだけでこれを行うことができます。しかし、しないでください。ブラウザが新しいウィンドウをどのように表示するかを制御することはできません。ウィンドウを表示する(タブを使用する、言い換えれば)こともできます。ウィンドウのフォーカスポリシーを制御することはできません。全体的には、人々のためにたくさんの新しいウィンドウを開くのは良い考えではありません。 – Pointy
彼は真実を語っているので、@Odedを聞いてください。 –