admin管理员组文章数量:1024924
I used auto click code on my site with simple code and it worked. Below is the code which I used previously.
<script type="text/javascript">
$(document).ready(function(){
var list = document.getElementsByClassName("link");
for (var i=0; i<list.length; i++) list[i].click();
});
</script>
<div>
<a href="#" target="_top" class="link">CLick</a>
</div>
But this time my code is little plicated. I was thinking: is it possible to auto-click the ad, which is created after running of the ad script code? Below is the somewhat same html part of the ad or please check the actual html on .html
<div>
<div id="ac_152518">
<div class="ac_header_title">What Others Are Reading</div>
<div class="ac_adbox"><div class="ac_adbox_inner">
<div class="ac_container">
<a class="ac_image_link" rel="nofollow" target="_blank" href='xyz">
<img height="250" width="300" src="abc.jpg" class="ac_image">
</a>
</div></div></div></div></div>
I just want to auto-click the "ac_image_link" href element on the page load. P.S: I am not doing this for earning $$ just to satisfy myself that it is possible or not.
I used auto click code on my site with simple code and it worked. Below is the code which I used previously.
<script type="text/javascript">
$(document).ready(function(){
var list = document.getElementsByClassName("link");
for (var i=0; i<list.length; i++) list[i].click();
});
</script>
<div>
<a href="#" target="_top" class="link">CLick</a>
</div>
But this time my code is little plicated. I was thinking: is it possible to auto-click the ad, which is created after running of the ad script code? Below is the somewhat same html part of the ad or please check the actual html on http://www.meansim./adtest.html
<div>
<div id="ac_152518">
<div class="ac_header_title">What Others Are Reading</div>
<div class="ac_adbox"><div class="ac_adbox_inner">
<div class="ac_container">
<a class="ac_image_link" rel="nofollow" target="_blank" href='xyz.">
<img height="250" width="300" src="abc.jpg" class="ac_image">
</a>
</div></div></div></div></div>
I just want to auto-click the "ac_image_link" href element on the page load. P.S: I am not doing this for earning $$ just to satisfy myself that it is possible or not.
Share Improve this question asked Apr 23, 2016 at 17:21 Sagar HiranandaniSagar Hiranandani 111 gold badge1 silver badge3 bronze badges1 Answer
Reset to default 2are you still using jQuery? If yes, same as in your first example, when the document is ready:
$('.ac_image_link').click();
or
$('.ac_image_link').trigger("click");
UPDATE 2:
Be ensure that your AdBlocker is disabled, because your element gets immediately eliminated if enabled. For your situation, use this approach:
$(document).ready(function(){
var link = $('.ac_image_link').attr('href');
window.location.href = link;
});
or if it is a static link:
$(document).ready(function(){
window.location.href = "http://www.google./";
});
Hope it works now :)
I used auto click code on my site with simple code and it worked. Below is the code which I used previously.
<script type="text/javascript">
$(document).ready(function(){
var list = document.getElementsByClassName("link");
for (var i=0; i<list.length; i++) list[i].click();
});
</script>
<div>
<a href="#" target="_top" class="link">CLick</a>
</div>
But this time my code is little plicated. I was thinking: is it possible to auto-click the ad, which is created after running of the ad script code? Below is the somewhat same html part of the ad or please check the actual html on .html
<div>
<div id="ac_152518">
<div class="ac_header_title">What Others Are Reading</div>
<div class="ac_adbox"><div class="ac_adbox_inner">
<div class="ac_container">
<a class="ac_image_link" rel="nofollow" target="_blank" href='xyz">
<img height="250" width="300" src="abc.jpg" class="ac_image">
</a>
</div></div></div></div></div>
I just want to auto-click the "ac_image_link" href element on the page load. P.S: I am not doing this for earning $$ just to satisfy myself that it is possible or not.
I used auto click code on my site with simple code and it worked. Below is the code which I used previously.
<script type="text/javascript">
$(document).ready(function(){
var list = document.getElementsByClassName("link");
for (var i=0; i<list.length; i++) list[i].click();
});
</script>
<div>
<a href="#" target="_top" class="link">CLick</a>
</div>
But this time my code is little plicated. I was thinking: is it possible to auto-click the ad, which is created after running of the ad script code? Below is the somewhat same html part of the ad or please check the actual html on http://www.meansim./adtest.html
<div>
<div id="ac_152518">
<div class="ac_header_title">What Others Are Reading</div>
<div class="ac_adbox"><div class="ac_adbox_inner">
<div class="ac_container">
<a class="ac_image_link" rel="nofollow" target="_blank" href='xyz.">
<img height="250" width="300" src="abc.jpg" class="ac_image">
</a>
</div></div></div></div></div>
I just want to auto-click the "ac_image_link" href element on the page load. P.S: I am not doing this for earning $$ just to satisfy myself that it is possible or not.
Share Improve this question asked Apr 23, 2016 at 17:21 Sagar HiranandaniSagar Hiranandani 111 gold badge1 silver badge3 bronze badges1 Answer
Reset to default 2are you still using jQuery? If yes, same as in your first example, when the document is ready:
$('.ac_image_link').click();
or
$('.ac_image_link').trigger("click");
UPDATE 2:
Be ensure that your AdBlocker is disabled, because your element gets immediately eliminated if enabled. For your situation, use this approach:
$(document).ready(function(){
var link = $('.ac_image_link').attr('href');
window.location.href = link;
});
or if it is a static link:
$(document).ready(function(){
window.location.href = "http://www.google./";
});
Hope it works now :)
本文标签: javascriptAuto click on linkad after page loadStack Overflow
版权声明:本文标题:javascript - Auto click on linkad after page load - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745511213a2153834.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论