/    Sign up×
Community /Pin to ProfileBookmark

javascript re-direct question

hi guys can you tell me which is the best way
to perform a javascript redirect that will work
with all the major browsers – IE, FF, CHROME,etc?

[CODE]var url = “http://www.whatever.com”;

window.location = url;

or

location.href = url;[/CODE]

any suggestions?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@MrRedFeb 19.2009 — I seem to be the first to answer this question often - try searching older threads first it will save you time.
self.location.replace("http://cresby.com"); in a frame

orparent.location.replace("http://stroudceilidhs.co.uk"); for replacing a all (eg frameset).
Copy linkTweet thisAlerts:
@bsmbahamasauthorFeb 19.2009 — i used window.location.href = "http://www.abc.com";

seems to work with with ot without 'self' or 'window' too.

i know several ways to do it, and was mostly concerned with

finding which way would work in the major browsers.
×

Success!

Help @bsmbahamas spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...