[英]onclick inside iframe for a button outside iframe
I am trying to find a way to initiate an onclick
inside an iframe when a button outside the iframe is clicked. 我试图找到一种方法,当单击iframe外部的按钮时,即可在iframe中启动
onclick
。
The code for the onclick
is included below. 下面包含了
onclick
的代码。
<div style='float: right;'>
<a href='javascript:void(0)' onclick ='xnaww_download()' data-tooltip-ul="Download map data of a selected region. Output data is in KML format">
</div>
You need to have the following script from the parent page (assuming you are using jQuery and the id of the iFrame is "iframeElement"): 您需要从父页面获得以下脚本(假设您使用的是jQuery,而iFrame的ID为“ iframeElement”):
$("#iframeElement")[0].contentWindow.xnaww_download();
This will only work as long as the parent and frame are on the same domain. 只要父级和框架位于同一个域中,这将仅起作用。 Otherwise you'll run into cross-domain-scripting errors!
否则,您将遇到跨域脚本错误!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.