iframe 获取值无法将console.log的对象转换为 string
2017-03-14 22:25
363 查看
<iframe src="" name="bb" id="iframe1" ></iframe> <div onclick="test()">tesxr</div> <div onclick="bobo()">bbb</div> <script type="text/javascript"> window.open('http://wenku.baidu.com/view/30f1188fd15abe23482f4dcc.html','bb'); //将http://wenku.baidu.com的内容放入iframe中,为跨域 window.open('./base.html','bb'); //把同域中的内容放入iframe中,为同域 function test(){ console.log(window.document.getElementsByTagName('iframe')[0].contentWindow.document); //可获取同域中的对象,但是不能获取跨域的console.log(window.document.getElementsByTagName('iframe')[0].contentWindow.document); var html=window.document.getElementsByTagName('iframe')[0]; console.log(html); //通过console.log可以打印出跨域iframe中的内容,为一个object 但是无法将其转换为字符串!!!!?是个问题~` htmlS=html.toString; htmlT=JSON.stringify(html); htmlW=html.toString() console.log(JSON.stringify(html)) var htmlStr=JSON.stringify(html); alert(html.toString()) var substr = htmlStr.match(/body(\S*)body/); alert(substr) console.log(window.document.getElementsByTagName('iframe')[0]); } function bobo(){ alert(htmlS); alert(htmlT); alert(htmlW) } </script>
相关文章推荐
- 无法将类型为“System.DBNull”的对象强制转换为类型“System.String”分析及解决方案
- 日期工具类(获取两日期之前相差天数及String/Timestamp/Date对象之前的日期转换)
- c#:无法将类型为“System.DBNull”的对象强制转换为类型“System.String”
- ASP.NET.MVC异常--无法将类型为System.Int32的对象强制转换为类型System.String
- jQuery怎么操作json对象jsonTest(即json类型的string,但是要先将string转换为json对象),获取对象属性、获取对象数组的某个对象
- 获取或转换XML对象,从string和URL中获取
- 无法将类型为“System.DBNull”的对象强制转换为类型“System.String”
- httpResponse的getEntity为空,获取了这个数据在解析的时候出现了String不能转换成json对象
- 无法将类型为“System.Int32”的对象强制转换为类型“System.String”
- 无法将类型为“System.DBNull”的对象强制转换为类型“System.String”。
- android JSON获取值String无法转换成JSONObject
- Node.js访问SQLite数据库获取数据时出错 JSON对象无法转换
- 关于MVC中无法将类型为“System.Int32”的对象强制转换为类型“System.String”的问题。
- C# 类型“System.String”的对象无法转换为类型“System.Int32”
- VS C# 获取系统当前时间+timer的作用+无法将类型“int”隐式转换为“string”;
- Linq集合查询出现无法将类型为“System.Int32”的对象强制转换为类型“System.String”异常
- 类型“System.String”的对象无法转换为类型“System.Char”。
- 无法获取 java Console 对象
- C# 无法将类型为“System.DBNull”的对象强制转换为类型“System.String”。
- 无法将类型为“Oracle.DataAccess.Types.OracleString”的对象强制转换为类型“System.String”。