그리고 의견을 공유하는 데 어려움을 겪은 모든 분들께 감사드립니다.
다음과 같은 자바 스크립트가 새 창 여는 데 사용되는 새 창으로 홈페이지에서 탐색 :
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 뒤에는 초점이 맞지 않았습니다.
새 창에는 '메뉴'버튼이 있습니다.
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를 들어야합니다. –