/    Sign up×
Community /Pin to ProfileBookmark

Javascript Bookmarklet–help required

Hello:

My code, which is in the form of a bookmark, is as such:

javascript:k=location.href;m=
document.domain;n=”www.live25.m”;
p=”live25.dev.live25.com”;
if(document.domain==n)
{k=k.replace(m,p);}else{k=k.replace
(m,n)}location.href=k

I need to add more domains to this bookmarklet, but I don’t
know what the appropriate syntax for adding another variable, that is, how would I write it so that I can add another block of code like the above, in the same bookmarklet, but replace “live25” with “live25h”?

I would probably need to add nine or ten different domains in.

Any help would be greatly appreciated.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@felgallJun 30.2007 — Just add a semicolon and another copy of the code (without the javascript: on the front). You just need to keep the total length under 2000 characters it will not work.
Copy linkTweet thisAlerts:
@dyoungauthorJun 30.2007 — Hi.

Thanks for the quick response. I tried what you suggested, but it had no results. Please let me know if you have any further suggestions, or any ideas about what I might be doing wrong.

Thanks again.
Copy linkTweet thisAlerts:
@Banana_AnandaJun 30.2007 — Could you explain the intended logic a little more. It's hard to see from the example how it would be extended. Are there pairs of domains ?
Copy linkTweet thisAlerts:
@dyoungauthorJun 30.2007 — Here's the intention:

I have three domains: live25, live25xy, live25zr

Each of these domains lives on a dev. and qa server; consequently, they, the domains, would need to change to the qa and dev. servers.

I hope this provides you with enough information.

Thanks.
×

Success!

Help @dyoung 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.2,
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,
)...