Forum Moderators: open

Message Too Old, No Replies

MAC OS & IE5.1

Problem with document.location.replace

         

Bhavink

9:05 pm on Jul 19, 2005 (gmt 0)

10+ Year Member



Hi,

I use a single line of code to reload/refresh my ASP page on one of the event for instance Cancel.

document.location.replace(page name)

The problem here is that the page is not reloaded/refreshed in MAC whereas it works as required in Windows.

Is there anything to do with the OS or I need to change the code itself to make it independent of the OS?

Your inputs will be highly appreciated.
Thank you.
~Bhavin

whoisgregg

5:17 am on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try either:
window.location.replace(whatever)
or
location.href='http://whatever'

I'm sure one or the other will work in all browsers, just can't remember which. :)

Bhavink

2:02 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



Hi,

Thanks for the help. But the option you provided did not work with IE 5.2 on MAC OS. It did work with IE 6 on Windows.

Sorry for mentioning the incorrect version of IE.

Let me know if you have any clues about this.

Regards,
Bhavin

whoisgregg

3:50 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's strange. If you visit the Apple [apple.com] website in Mac IE 5.2.3, there is a select jump menu at the bottom to go to different country sites that works using this code:

<select name="worldwide" onchange="[b]location.href=[/b][i]the new page[/i]">

I'm stumped. It should be working. Perhaps there is other javascript on the page conflicting?

Bhavink

4:06 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



Thanks for quick reply.

document.location.replace("");
This line of code is within If condition. The If condition basically checks if user has made any changes to the current page. If yes, then a message if displayed with Ok & Cancel button.

On clicking Ok button, document.location.replace gets executed, which in turn redirects to the page within the replace method. On clicking Cancel button nothing happens.

Am kinda stuck with this. Anyways thanks for your help.

whoisgregg

8:03 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not to beat a dead horse, but this test page works in Mac IE 5.2.3 (and a few other Mac browsers I tested):

<html>
<head>
<script>
function checkchanges() {
if(document.getElementById("check").checked){
document.location.replace("http://www.webmasterworld.com/");
}
}
</script>
</head>
<body>
<input type="checkbox" value="1" name="check" id="check" />
<button onclick="checkchanges()">submit</button>
</body>
</html>

And also works with this syntax for the redirect line:

location.href="http://www.webmasterworld.com/";

So, it's not that part of your code that is breaking. :)

How are you showing the user a dialog box? That bit of code may provide insight into the error.

Bhavink

8:43 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



I checked out your code and it works fine.

Well my code has a function that checks for any changes. This function lies in another .js file, which is included in the ASP page.

I will check out this function and come back to you.

Thanks for all your help.

Bhavink

8:48 pm on Jul 21, 2005 (gmt 0)

10+ Year Member



I realised one more thing. The way the ASP file is referenced in the replace method.

The existing code is written in this fashion
document.location.replace(abcd.asp)

where abcd.asp can be the same page or another page.

I assume that the way this ASP page is referenced is incorrect and that is the reason why is does not refresh or re-direct to the page mentioned in the replace method.

Please correct me if am wrong. And also let me know any alternative to this.

Thank you.

whoisgregg

4:58 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does it have quotes around the url?

document.location.replace("abcd.asp")

Bhavink

6:14 pm on Jul 22, 2005 (gmt 0)

10+ Year Member



Thanks once again.

I tried with both the type of quotes - Single and Double quotes but it still doesn't work.

I have to check about the way the page validation is done. Since the code you provided about re-directing to "webmasterworld.com" page worked.