I have some sites mysite1.com
, mysite2.com
,.... mysiten.com
All mysite1-n.com
using external javascript on myexternalsite.com/mainfile.js
I want,
if ( mysite1-n.com
) visitors come from www.google.com
then will redirect to welcome.com
if ( mysite1-n.com
) visitors come from www.yahoo.com
then will redirect to welcome2.com
if ( mysite1-n.com
) visitors come from www.anotherdomain.com
then will call javascript on myexternalsite.com/file1.js
and working using this script
And if ( mysite1-n.com
) visitors come from bookmark then will call javascript on myexternalsite.com/file2.js
and working using this script
What sort of script should I be using on myexternalsite.com/mainfile.js
?
Thank's
basically you should check for document.referrer value and the document.location.href to do achieve what you want. This with a bunch of regexp should do the trick easily.
ex:
if( document.location.href.match(/^https?:\/\/mysite1-n.com/) ){
if( document.referrer.match(/google.com/) ){
window.location = 'http://welcome.com';
}
var s = document.createElement('script');
s.src = 'myexternalsite.com/mainfile.js';
document.head.appendChild(s);
}
and so on
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.