/    Sign up×
Community /Pin to ProfileBookmark

"Must visit from" javascript wont work in IE…

I have obtained the following script which only lets a page load if the visitor has been to the previous page, if they haven’t it sends the visitor to the appropriate page. However, it only works in Mozilla. Can anyone help me adapt this script to work in Internet Explorer?

[CODE]
<SCRIPT LANGUAGE=”JavaScript” > <!– Begin var requiredfrom = “http://domain.com/somepage.htm”; // required prev. page if (document.referrer.indexOf(requiredfrom) == -1) { alert(“You must logon first…”); window.location=requiredfrom; } // End –> </script>
[/CODE]

Cheers,
NuGG

P.S. you can find an example [URL=http://kings-head-inn.com/fudge/success.htm]here[/URL]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoNov 25.2005 — <i>
</i>&lt;SCRIPT LANGUAGE="JavaScript"&gt;
var refarray = new Array();
refarray[0] = new Array();
refarray[0] = ['mysite.com']['redirectsinceitisfromyoursite]
var i;

for (i=0;i&lt;refarray.length;i++)
{
if (document.referrer!=refarray[i])
{
window.location.replace('pagetoredirecto.html');
}
else
{
window.location.replace(refarray[i][1]);
}
}
&lt;/script&gt;
Copy linkTweet thisAlerts:
@NuGGauthorNov 25.2005 — That doesnt script appear to work either as you can access the page without visiting the required previous page. Or it could be that ive edited it wrong or something. Take a look:

[CODE]<SCRIPT LANGUAGE="JavaScript">
var refarray = new Array();
refarray[0] = new Array();
refarray[0] = ['www.kings-head-inn.com']['redirectsinceitisfromyoursite] [B]\What goes here? I dont really understand...[/B]
var i;

for (i=0;i<refarray.length;i++)
{
if (document.referrer!=refarray[i])
{
window.location.replace('http://www.kings-head-inn.com/fudge/index.htm');
}
else
{
window.location.replace(refarray[i][1]);
}
}
</script>
[/CODE]


I want it to only allow people to access the http://www.kings-head-inn.com/fudge/[B]Success.htm[/B] page if they have just been on the http://www.kings-head-inn.com/fudge/[B]index.htm[/B] page.
Copy linkTweet thisAlerts:
@felgallNov 25.2005 — document.referrer is one of those fields that might contain the last page visited or might contain blank.

It contains blank if the field is turned off by your visitor in their web browser or firewall. It is also blank when coming from a secure page in IE.
×

Success!

Help @NuGG 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.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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