I found two javascripts that I would like to combine.
First one:
<script type="text/javascript">
function checker(url) {
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
var referLink = document.createElement('a');
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
} else {
location.href = url;
}
}
checker("http://check");
</script>
And what that one does is pass the refer in IE
The second one:
<script language="JavaScript">
if (document.referrer.indexOf('somesite.com') > -1)
location.href='http://promo.com/';
else
location.href='http://mysite.com';
</script>
And the code above checks on where to send the user based if they are refered from the site they come from. I was trying to combine them into a single script. So I thought this would work:
<script type="text/javascript">
if (document.referrer.indexOf('somesite.com') > -1)
function check(url) {
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
var referLink = document.createElement('a');
referLink.href = url;
document.body.appendChild(referLink);
referLink.click();
} else {
location.href = url;
}
}
check("http://check");
else
location.href='http://mysite.com'
</script>
Any suggestion?