我試圖在關閉瀏覽器時模擬h:commandButton中的onclick事件。模擬鉻中的onclick事件問題
這裏是我的代碼:
<body onBeforeUnload='closingBrowser()'>
function closingBrowser() {
document.getElementById('main:commandButtonHidden').onclick();
return false;
}
此javascript函數調用它有這個定義與我的按鈕相關的功能:
<h:commandButton id="commandButtonHidden"
value="checkPasswords().Login"
onclick="javascript:checkPasswords();" actionListener="#{init.closingBrowser}" />
和checkPasswords():
function checkPasswords() {
alert("checkPasswords");
return true;
}
這個函數沒有什麼意思,因爲我想要的是我的actionListener中的函數。
這在IE和FF中非常適用,但不適用於Chrome或Opera。
警報總是會在所有瀏覽器中觸發,但actionListener NO只在IE和FF中無效。
有人對此有所瞭解。
感謝
什麼是H:的commandButton? – 2010-10-12 19:55:08
你能更清楚嗎?有什麼不對。該代碼在IE和FF中可以正常工作,actionListener不會在Chrome和Opera中觸發,但是如果直接點擊該按鈕,則可以在4個瀏覽器中完美工作。謝謝。 – 2010-10-15 18:13:19