views:

476

answers:

2

I'm seeing the following exception in FF 3.5.6:

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") on the parent window of an iframe.

It's also reproducible in FF2, but IE8 doesn't exhibit the problem.

EDIT: The following code in the same context doesn't have the problem:

document.location.reload();
A: 
location.replace()

is an error. You must pass an address into the replace method as an argument. Otherwise you're effectively passing in undefined, which as the “URI is malformed” message would suggest, is not a valid address.

I don't know what you're trying to do... if you want to reload the page you should indeed use location.reload(). But ‘replace the current location's URI with (nothing)’ is meaningless.

bobince
I updated the question, it's being replaced with a relative URL. I was only indicating that I was calling .replace.
jthompson
A: 

The solution I came up with for this was to compose an absolute URL and assigning it to window.location. Reload() 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)
}
jthompson