I am trying to find a way to initiate an onclick
inside an iframe when a button outside the iframe is clicked.
The code for the onclick
is included below.
<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"):
$("#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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.