javascript - js click onpage load based on referrer -
i need js clicked when page load based on referrer. when user came fixed domain name, form auto clicked. else nothing.
example: need when user came www.example.com or example.com or example.com/anypage/ in mysite.com/userinfo/ ... form automatically submitted. if not came example.com .. nothing happned.
when use without referrer code au submit.. works , click .. click.. click.. on every load...and continuously clicked...
<script type="text/javascript"> document.getelementbyid("sendit").submit(); </script>
then try use referrer code... after add referrer code.. not work again.. can do??
<script type="text/javascript"> if (document.referrer == ("http://aweber.com" || "http://www.aweber.com")) { document.getelementbyid("sendit").submit(); } </script>
i use method:
<script type="text/javascript"> $( document ).ready(function() { if (document.referrer == "www.aweber.com") { $("#sendit").submit(); } else { /* nothing */ } }); </script>
any idea???
in line:
if (document.referrer == ("http://aweber.com" || "http://www.aweber.com")) {
you attempting using javascript assignment technique instead of comparing result of document.referrer.
your statement should be:
if ((document.referrer == "http://aweber.com") || (document.referrer = "http://www.aweber.com")) {
Comments
Post a Comment