<html>
<body>
<iframe id="myFrame" src="/index.html" name="iframe_a"></iframe>
<p>单击该按钮可显示 iframe 的名称。</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myFrame").name;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>