访问outerHTML

时间:2015-10-26 19:37:32

标签: javascript html iframe

我有一个来自IFRAME的HTML DOM元素。我试图获取该IFRAME的内容,但每当我得到outerHTML时,它都会被截断。

以下是代码示例:

var htmlElm = frame.contents().children()[0];
console.log(htmlElm);  //inspect this, i see the outerHTML as i would expect
console.log(htmlElm.outerHTML); //not what was in the chrome inspector,
                                //i get a truncated version

这是一个被截断的HTML示例,至少对我而言:

<!DOCTYPE html>
<html>
<head>
  <title>Title</title>
  <link href="https://example.com/stylesheet.css" rel="stylesheet">
  <script type="text/javascript">
    function test() {
       window.alert('test');
    }
  </script>
</head>
<body>
  <h1>Body</h1>
</body>
</html>

0 个答案:

没有答案