/    Sign up×
Community /Pin to ProfileBookmark

How to branch location according to what network I’m on

I’m trying to write a script that will tell if my wife’s laptop is on my home network or not.

If it’s on home, it will branch to a page on my webserver at home, otherwise it will look for the intranet server at my wife’s office. I’d like a third option if she goes online in a hotel or such.

There doesn’t seem to be a way to read an IP or gateway address from Javascript, and I’ve been unable to find a method that will return URL availability, i.e. something along the lines of;

[CODE]if (isAvailable(http://homeserver/)) {
window.location = “http://homeserver/”;
} else if (isAvailable(http://work-intranet/)){
window.location = “http://work-intranet/”;
} else {
window.location = “file:///c|fallbackpage.htm”
}[/CODE]

I’d put this in a default page on the laptop, and have it carry her to the appropriate location.

I simply haven’t been able to find something that will return information about the environment or the availability of a given URL.

I’m sure I’m not the first one to try this. Does any one have any ideas?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @scaiferw 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 5.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...