/    Sign up×
Community /Pin to ProfileBookmark

force browser url

when someone goes to my site like so: [url]http://company.com[/url]
i would like the url to change to [url]http://www.company.com[/url] … can JS force this client side? or should this be done server side

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@fredmvFeb 18.2004 — I don't see the point. It can be done with JavaScript but server-side is preferred.
Copy linkTweet thisAlerts:
@catchupauthorFeb 18.2004 — clarity: i have an embeded swf that does things dynamically and and because of the security measures of flash, if a user types in http://company.com and then performs an operation in the movie the security feature kicks in cause it reads http://company.com and http://www.company.com as two different sites. So i'm trying to set the record straight for user convience sake. any snipletts? I tried this in ASP with http_refer but this seemed futile against proxy servers and certain firewalls...
Copy linkTweet thisAlerts:
@fredmvFeb 18.2004 — I see. Perhaps try something like this:<script type="text/javascript">
//<![CDATA[
onload = function()
{
if(!/^http://www./.test(location.href)) location = 'http://www.foo.com/';
}
//]]>
</script>
×

Success!

Help @catchup 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.17,
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,
)...