/    Sign up×
Community /Pin to ProfileBookmark

I need to know where they come from

Hi! I’m a beginner in this area but somebody told me what I want can be done with Java. What I want is: a link that only appears on a webpage if the person viewing the page has arrived from outside my domain. If the person has reached the page from within my domain no link is to be showed. Is this possible? Can anyone help me with this?

Thanks,
Petter Ilander, Finland

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@VladdyNov 21.2002 — Since you are posting on JavaScript forum I assume you are looking for a client-side code. The more reliable way to accomplish the task is using server side scripting so it works regardless of javascript being enabled.

If for some reason server side implementation is not possible, you can do the following:

give the link you are trying to hide an id

use onload event to examine the document.referrer

if it matches your URL then use getElementById to access the link and [element].removeNode to get rid of it. You can also use [element].style.visibility to hide it, if removing the node affects your document flow.
Copy linkTweet thisAlerts:
@opilanderauthorNov 21.2002 — Yeah. I guess you're right, Dave. I've only copied and pasted JavaScript so far, and although vladdy's answer seems to be just what I want, I can't write the script?

Is it too much to ask, or could somebody please help and show me how to write the script?

The pages concerned are: www.uwasa.fi/~h79188/artikkelit/aminohappo.html

which is the page that should have a link to:

www.uwasa.fi/~h79188/artikkelit.html when people come from outside of my domain but not when from inside it.

Thanks!!
×

Success!

Help @opilander 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.18,
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,
)...