/    Sign up×
Community /Pin to ProfileBookmark

Variable determined by host name?

Is this the correct syntax?

// Determine domain used to access site
if (top.location.host.indexOf(‘.com’)) {
var DefaultURL = ‘http://www.sitename.com‘;
}
if (top.location.host.indexOf(‘.org’)) {
var DefaultURL = ‘http://www.sitename.org‘;
}

I need assign this variable based on how the site was accessed — either .org or .com. Thank you for your help!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@msmith29063authorJun 17.2003 — Thanks, Dave. I wasn't gonna bug you with this issue. But thanks for the help! You've been great. I've really learned a lot!
×

Success!

Help @msmith29063 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.1,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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