【发布时间】:2014-01-02 17:47:12
【问题描述】:
我有html代码
网站索引.html
<html>
<body>
<iframe id="html2" frameborder="0" src="html2.htm" marginwidth="0" marginheight="0" style="height: 492px;"></iframe>
</body>
</html>
网站 html2.htm
<html>
<body>
<div><p id='123'>hello</p></div>
</body>
</html>
当我在站点 index.html 中使用 document.getElementById('123') return = null;
我怎么能得到它
【问题讨论】:
-
可能重复:stackoverflow.com/questions/1088544/… 另外,id 不能以数字开头,如果 iframed 页面位于不同的域中,这将根本不起作用。
-
欢迎新用户。跟我去后街吧。我会告诉你一个小技巧:stackoverflow.com/tour
-
@m59 你扼杀了我缩进代码的冲动。谢谢。
-
@MilchePatern 嗯?我很着迷,哈哈。
标签: javascript html iframe