Javascript获取IFrame内容(兼容IE&FF)
时间: 2008-12-26
在网上找到在IE下操作IFrame内容的代码:
但是这在Firefox下无效。
所以,想到在Firefox下用FireBug来调试。经过调试发现在Firefox下可用以下代码来实现:
详细代码如下:
TestIFrame.htm:
<head>
<script type="text/javascript">
function f(){
var doc;
if (document.all){//IE
doc = document.frames["MyIFrame"].document;
}else{//Firefox
doc = document.getElementById("MyIFrame").contentDocument;
}
doc.getElementById("s").style.color="blue";
}
</script>
</head>
<body onload="f()">
<iframe id = "MyIFrame" name = "MyIFrame" src = "MyIFrame.htm" width = "100" height="100">
</body>
</html>
MyIFrame.htm:
附件内容:
1.TestIFrame.htm
2.MyIFrame.htm
本文出自 “wintysのブログ” 博客,请务必保留此出处http://wintys.blog.51cto.com/425414/123303
Javascript获取IFrame内容(兼容IE&FF)的更多相关文章
- javascript获取iframe框架中页面document对象,获取子页面里面的内容,iframe获取父页面的元素,
javascript获取iframe框架中,加载的页面document对象 因为浏览器安全限制,对跨域访问的页面,其document对象无法读取.设置属性 function getDocument(i ...
- javascript 获取iframe里页面中元素值的方法 关于contentWindow和contentDocumen
javascript 获取iframe里页面中元素值的方法 IE方法:document.frames['myFrame'].document.getElementById('test').value; ...
- JavaScript获取地址栏内容
例如地址为:http://www.mazey.net/baby/blog/index.php?a=1&b=2#c var query = window.location.href; //htt ...
- javascript 获取iframe元素的方法
javascript 获取iframe元素的方法 第一种: $("#IframeID").contents().find("div"); 第二种: $(win ...
- javascript 获取iframe中的dom
太扯了,一个多小时都没搞定,获取不到iframe中的dom元素. <div id="one"> this is one </div> <div> ...
- JS/javaScript 获取div内容
jquery: 例如<div id="abc"><a>内容</a></div>$("#abc").html(); ...
- JavaScript获取输入框内容
html: <input name="money" type="number" placeholder="税前工资"><b ...
- 获取iframe 内容
parent.$.find("iframe")[0].contentWindow.getvalue(); h.find("iframe")[0].content ...
- layer获取iframe内容
var layer1 = function() { layer.open({ type: 2, title: '标题', maxmin: false, area: ['780px', '600px'] ...
随机推荐
- UI设计 - 首页(主页)的任务
什么是首页 首页,又可以叫主页,是我们的网站或者APP的主要页面,它是我们接触的第一个页面(如果不包含闪屏页和登陆页的话). 特点 首页是一个开始的地方,我们开始真正接触网站提供给我们的内容. 首页是 ...
- im ui框架调研,对比
1, https://github.com/jpush/aurora-imui 极光的 支持 Android/iOS/RN 提供了消息列表.输入视图 功能不多, 2,https://github.co ...
- XmlnsDefinition for a Cool Namespace Mapping
In XAML, when you want to reference a CLR type, you have to add a namespace mapping that maps the XM ...
- C++标准转换运算符static_cast
该运算符把expression转换为type-id类型,但没有运行时类型检查来保证转换的安全性. 中文名 暂无 外文名 static_cast 分 类 强制类型转换 类 型 C++ s ...
- python-下载百度图片到本地
import requests import os def getManyPages(keyword,pages): params=[] for i in range(30,30*pages+30,3 ...
- Java如何暂停线程一段时间?
在Java编程中,如何暂停线程一段时间? 以下示例显示如何通过创建sleepThread()方法来暂停线程一段时间. package com.yiibai; public class Suspendi ...
- Java如何监视线程的状态?
在Java编程中,如何监视线程的状态? 以下示例演示如何通过扩展Thread类并使用currentThread.getName()方法来监视线程的状态. package com.yiibai; cla ...
- e797. 显示JSlider的标记
The slider supports two levels of tick marks, major and minor. Typically, the minor tick-mark spacin ...
- Unity GUI(uGUI)使用心得与性能总结
Unity GUI(uGUI)使用心得与性能总结 作者 kingshijie 关注 2015.09.26 15:35 字数 3686 阅读 28031评论 10喜欢 49 背景和目的 小哈接触Unit ...
- 本地没问题 服务器 提示 Server Error in '/' Application
一. 先用本机的 IIS 测试,不要用 VS 内附的 Web server,並配置 <customErrors mode="Off"/>,以將真實的錯誤原因顯示出來,看 ...