I have a function to open a page in a dialog box instead of the main window. A bit cleaned up code is the following:
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]
});
}
This code works fine in Chrome, but the (status == “error”) is executed under Firefox. Seemingly there is a 404 error for Firefox, might be an image of the loaded page, or something similar.
Any ideas how to get the Chrome behavior under Firefox too?
(you can find a working example here)
In FireFox, window.location.origin is
undefined. FireFox therefore tires to get the page:http://openerp.co.hu/hu/funkcionalis-bemutato/undefined/static/docs/sales.htmland fails
In chrome, window.location.origin
http://openerp.co.hu. Chrome ties to get the page:http://openerp.co.hu/static/docs/sales.htmland succeeds
Instead of relying on
window.location.origin, try using: