我在 index.html 上有这段代码
<body>
<iframe id=iframetest src="alt.html">
<p>Your browser does not support iframes.</p>
</iframe>
<script>
$(window).load(function(){
document.getElementById('iframetest').contentWindow.myFunction();
});
</script>
<button onclick="myFunction();">Click Me</button>
</body>
这个 1 在 alt.html 中
<head>
<title>JavaScript Test</title>
<script type="text/javascript">
//When click on the button function will run
function myFunction(){
alert("Hello World");
}
</script>
</head>
<body>
<h1>TEST</h1>
</body>
我想在 index.html 中显示警报。但这不起作用。我该怎么做?请帮助我
谢谢你!