我有一個函數可以在對話框而不是主窗口中打開一個頁面。清理代碼有點如下:jQuery.load()在Firefox下響應錯誤,在Chrome下正常工作
var baseurl = window.location.origin + '/static/docs/'
function onClickLink(event) {
event.preventDefault();
if($("#dialog").length==0) {
setUpDialog()
}
var href = event.target.href;
href = baseurl + href.substring(1+href.lastIndexOf('/'));
$("#dialog").load(href + ' .body', function(response, status, xhr) {
if (status == "error") {
window.location = event.target.href;
} else {
changeImageSrc();
reStructure();
}
});
$("#dialog").dialog({
modal:true,
title:event.target.text,
width: 960,
position: ['center', 100]
});
}
此代碼在Chrome中工作正常,但(狀態==「錯誤」)在火狐下執行。看起來Firefox有一個404錯誤,可能是加載頁面的圖像,或類似的東西。
任何想法如何獲得在Firefox下的Chrome行爲嗎? (你可以找到一個工作example here)
在baseurl上執行alert()以測試變量在兩個瀏覽器上的值是否相同 – Curt 2011-03-21 09:43:43
'window.location.origin'未定義。 – 2011-03-21 10:07:58