[英]How to call Javascript in href in main window from iframe?
我在iframe中有一個超鏈接。
<a href="JavaScript:openRec('8888')">Click here</a>
在父窗口中,我有一個腳本,其中聲明了openRec
函數。 如何從iframe調用此函數?
檢查https://developer.mozilla.org/en/DOM/window.parent
<a onclick="parent.openRec('8888');" href="#" >Click here</a>
要么
<a href="JavaScript:parent.openRec('8888');" >Click here</a>
如果父窗口和iframe屬於同一域,則此方法應該有效。
它可能無法在跨域方案中工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.