【问题标题】:When mouse over link click on my ad with jQuery当鼠标悬停在链接上时,使用 jQuery 点击我的广告
【发布时间】:2015-09-16 21:03:03
【问题描述】:

我的网页中有一个按钮Download。在这个按钮下我有一个iframe

<iframe width="468px" height="60px" frameborder="0" src="http://ads.xxxxxx.com/show_ad.php?id=12535"></iframe>

当客户点击Download 按钮时,有没有办法让它也有效地点击按钮下方 iframe 中的广告?

【问题讨论】:

  • 你想做什么?您需要什么帮助?
  • 也许我理解错了,但是当有人实际点击您页面上的按钮时,听起来您正试图触发对广告的点击。这对我来说听起来相当具有欺骗性。你应该让你的广告足够吸引他们想要点击它。这样做是不诚实的,应该受到所有有信誉的网络开发人员的强烈反对。
  • 我的广告面板中有太多广告客户,我希望每加载 20 个页面就获得一些印象

标签: jquery button click


【解决方案1】:

根据您的情况,如果广告页面是由您内部托管的,您可以这样做:

第 1 页:

<button id="btn">Download</button>
<br>
<iframe width="468px" height="60px" frameborder="0" id="frm1" src="http://ads.xxxxxx.com/show_ad.php?id=12535"></iframe>

<script>
$("#btn").click(function()
{
   $("#frm1").attr("src",$("#frm1").attr("src") + "&click=true");   
});


</script>

第 2 页:(您的广告网址)

$().ready(function()
{
   if(getUrlParameter('click') == true)
    $("#idOfAdInPage2").click();
});

var getUrlParameter = function getUrlParameter(sParam) {
    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : sParameterName[1];
        }
    }
};

你可以看看这个小提琴更好地理解:http://jsfiddle.net/p5g399L1/

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2011-05-20
  • 2012-10-16
  • 1970-01-01
  • 2021-03-04
  • 1970-01-01
  • 1970-01-01
  • 2014-03-28
  • 1970-01-01
相关资源
最近更新 更多