Forum Moderators: open

Message Too Old, No Replies

window.back() not working in Safari

         

rlcarr

2:25 pm on Oct 3, 2006 (gmt 0)

10+ Year Member



I'm running Safari 2.04 (419.3) on MacOSX 10.4.8.

I've noticed that when I hit some Javascript code that uses window.back(), the call does nothing. When I look at the Javascript console and tell it to log exceptions, I see the following:
"Value undefined (result of expression window.back) is not object."

The code works fine on FF on Mac, Linux, and Windows, and works
fine on IE on Windows.

Searching this site I saw someone had a similar problem with a different call (see [webmasterworld.com...] or search here for "Safari Javascript XML Problem") but got no answers.

Anyone have an idea on what's going on and what the error message means?

Thanks!

--
Rich

whoisgregg

7:24 pm on Oct 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I imagine that "window.back()" is supposed to evoke the browsers back button? If so, using "history.go(-1)" would be another way to accomplish the same thing and I believe it is much more compatible across different browsers.

penders

1:14 am on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



... or even "
history.back()
" - very similar to window.back() although not identical, but much more widely supported. [Same as whoisgregg's... history.go(-1)]

eelixduppy

1:53 am on Oct 4, 2006 (gmt 0)



Welcome to WebmasterWorld rlcarr!

You will find your experience here at WebmasterWorld very educational; just don't get addicted--you'll wind up like me ;)

WELCOME!

rlcarr

5:41 pm on Oct 4, 2006 (gmt 0)

10+ Year Member



Thank you very much and thanks for the welcome!

history.back() does do the trick.

Is that Safari error I saw Safari's generic way of saying
I used an unsupported/non-existent-in-Safari Javascript function?

penders

6:37 pm on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is that Safari error I saw Safari's generic way of saying
I used an unsupported/non-existent-in-Safari Javascript function?

Well, I guess so. FF would simply give, "window.dontexist is not a function" and IE would give, "Object does not support this property or method".