如何在加载页面时自动点击链接?不要重定向

时间:2013-05-23 15:15:15

标签: jquery

美好的一天。

在我的网站上,我有一个链接:

<a class="fancybox iframe" href="./online_order/form.php" id="online_form_a">

This link opens another page in an Iframe

</a>

点击页面上的链接加载iframe。

请告诉我如何在加载页面时iframe页面加载自动加载时自动点击?

2 个答案:

答案 0 :(得分:2)

你可以使用:

<script>
    window.location.replace("link.php");
</script>

我真的不建议这样做,因为html已经有了重定向用户的方法:

<meta http-equiv="refresh" content="0;URL=YOUR-LINK-HERE" /> 

更新:使用此选项触发点击页面加载:

<script>
$(document).ready(function() {
    // add the fancy box click handler here
    setTimeout(function() {
        $("#ExPRoG_online_form_a").trigger('click');
    },10);
});
</script>

答案 1 :(得分:0)

如果是某些AJAX操作,则应以其他方式触发,如果是重定向链接,则应使用window.location.replace()