Receptional Andy

msg:3761934 | 10:39 am on Oct 9, 2008 (gmt 0) |
You have the right idea - you need to loop through the array and check each entry against the referrer. Something like var myArray = []; myArray[0]= 'domain1'; myArray[1]= 'domain2';var currentReferrer=document.referer; var i; for (i=0;i<myArray.length;i++) // match() may be more effective than looking for an exact value if (myArray[i] === currentReferrer) { // the referrer matched one in the list alert("matched referrer"); } |
|
|
daveVk

msg:3761943 | 10:46 am on Oct 9, 2008 (gmt 0) |
Try these changes, you may also need to wait for page onload. <script language="JavaScript"> <!-- var myArray = [];
myArray[0]= 'domain1'; myArray[1]= 'domain2'; myArray[2]= 'domain3'; myArray[3]= 'domain4'; myArray[4]= 'domain5'; for(var i=0; i<5; i++) { if (document.referrer.indexOf(myArray[i]) > -1) { document.write('Some Text goes here'); }} //--> </script>
|
Rhys

msg:3761947 | 10:53 am on Oct 9, 2008 (gmt 0) |
Him Andy - thanks for the reply. It doesn't fit what I need - I need check "some word in the referrer's name is on a list"; not the whole referrer.
|
Rhys

msg:3761951 | 10:58 am on Oct 9, 2008 (gmt 0) |
Hi DaveVK - You're the Man - it worked instantly with your edits - many thanks. Rhys
|
|