/    Sign up×
Community /Pin to ProfileBookmark

Javascript array

Hey,

If you can see below im using the getHeader method in one of my jsp pages and i want to call that into a variable that will read the referrer.

Next it will go through my loop ad find a site and if that site is the referrer it will print whatever line of content is specified.

My problem is, i wont know the exact URL of the referrer, is there a way to identify the referrer maybe by using just a key word from the address bar?

ass you can see in my example i have [url]www.yahoo.com[/url], [url]www.msn.com[/url].. can i put a keyword in there for it to find in the url of the referrer?

[CODE]
<script type=”text/javascript”>
var referrer= “<% = request.getHeader(‘Referer’) %>”;

var mycontent = new Array();
mycontent[0]=’no from yahoo because..’
mycontent[1]=’your just come from a page containg a link called, Work!’
mycontent[2]=’no from msn because..’

if (referrer == “www.yahoo.com”) {
document.write(mycontent[0]);
}else if (referrer == “/messages-fw/internet/reftest.html”)
{document.write(mycontent[1]);
}else if (referrer == “www.msn.com”)
{document.write(mycontent[2]);
}else {
document.write(‘No Information!’);
}
</script>
[/CODE]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Lo0kBeHiNdUJun 18.2009 — What do you mean?

The [b].asp[/b] script fetches the 'Referer' Header.. so the way to get it is to type this in the url bar of the browser.

[b]http://www.yoursite.com/?Referer=The referrer url[/b]

So the [b].asp[/b] script will print out the 'The referrer url'.
Copy linkTweet thisAlerts:
@absolutmgd13authorJun 23.2009 — I used document.referrer which works fine.. in my referrer == "url" would it be possible to use a relative link or to use a string within the url.. say i wanted the script to pick up the site just by reading 'internet/reftest'

think that would be possible?
Copy linkTweet thisAlerts:
@absolutmgd13authorJun 23.2009 — my problem is.. i wont be able to add the ?= string to the url
×

Success!

Help @absolutmgd13 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.16,
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,
)...