NS_ERROR_MALFORMED_URI in FF when calling document.location.replace ()

In FF 3.5.6, I see the following exception:

uncaught exception: [Exception... "The URI is malformed" nsresult: "0x804b000a (NS_ERROR_MALFORMED_URI)" location: "JS frame :: http://x :: refreshPage :: line 193" data: no] 

This error occurs when calling document.location.replace ("/ relative / url") in the parent iframe.

It also plays in FF2, but IE8 does not detect a problem.

EDIT: The following code in the same context has no problem:

 document.location.reload(); 
+4
source share
2 answers

The solution I came up with was to make an absolute url and assign it to window.location. Rebooting () caused some problems with internal redirects.

 function get_full_url(url_path) { var loc = window.location; var url = "" + loc.protocol + "//" + loc.host + url_path; return url; } function refresh_page_absolute(url_path) { window.location.href = get_full_url(url_path) } 
+5
source
 location.replace() 

- error. You must pass the address to the replace method as an argument. Otherwise, you effectively go to undefined , which, as the message "URI is invalid" indicates, is not a valid address.

I do not know what you are trying to do ... if you want to reload the page, you really should use location.reload() . But "replacing the current location URI with (nothing) does not make sense.

+1
source

All Articles