两个不同的HTML文件如何相互调用?

新手上路,请多包涵

我在一个HTML文件(delete-window.html)中设计了一个可以弹出的窗口,在另一个HTML文件(delete-business.html)中想调用那个可以弹出的窗口,要如何调用。
代码:
1.

<delete-window>
<div class="ui basic modal" id="">
    <i class="close icon" onclick="$('.ui.basic.modal').modal('hide');"></i>
    <div class="header">
        Are you sure to delete?
    </div>
</delete-window>

2.

<delete-business>
<script>
function deleteBiz() {
    $('delete-window.ui.basic.modal').show();
}
</script>
</delete-business>
阅读 4.6k
1 个回答

这样调用,代码如下

页面1

<!DOCTYPE html>
<html lang="en">
    <head> 
        <meta charset="UTF-8" /> 
        <title>父页面</title>
 </head>
<script> 
function callback(e){ 
  alert(e)
} 
</script>
  <body>     
       <iframe src="index3.html"></iframe>
  </body>
</html>

页面2

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" /> 
        <title>子页面</title>
    </head>
    <script>
function opentargetWin(){ 
    window.parent.callback('调用目标弹出窗口!'); 
} 
    </script>
    <body> 
 <input type="button" value="打开窗口" onclick="opentargetWin()"> 
    </body>
    
</html>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题