简体   繁体   English

使用jQuery模拟链接的点击-在iframe之外,哪个链接指向另一个域?

[英]Using jQuery to simulate the click of a link - outside of an iframe, which links to another domain?

In my head this should be straight forward, but after testing I've discovered that it's not as easy as I thought! 在我看来,这应该很简单,但是经过测试,我发现这并不像我想的那么简单!

What I am trying to do is click a link outside of an iFrame, which will trigger a dynamic 'quick view' lightbox even within the parent site (which is on a different domain). 我想做的是单击iFrame外部的链接,即使在父网站(位于其他域中)内,该链接也会触发动态“快速查看”灯箱。

For example: 例如:

<a class="quickViewLink" href="#"> VIEW TO PURCHASE </a>

<iFrame src="http://www.google.com/">
  <a class="quickViewLink" href="#"> Clicking this will simulate the click of the link outside of this iframe </a>
</iFrame>

I have tried target="_parent" and also tried to use jQuery to target a specific link with no luck. 我尝试了target =“ _ parent”,还尝试使用jQuery定位没有运气的特定链接。

Any help would be greatly appreciated! 任何帮助将不胜感激!

EDIT: I do not have access to the site outside of the iFrame! 编辑:我无权访问iFrame之外的网站! (this is where I'm getting stuck) (这就是我被卡住的地方)

<a class="quickViewLink" href="#"> VIEW TO PURCHASE </a>
<script type="text/javascript">
    function clickLink() {
        $('.quickViewLink').trigger('click');
    }
</script>
<iFrame src="http://www.google.com/">
  <a href="javascript: window.parent.clickLink()" class="quickViewLink"> Clicking this will simulate the click of the link outside of this iframe </a>
</iFrame>

Use it with jQuery. 与jQuery一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM