×

iframe 属性 属性 js

js如何修改iframe 中元素的属性?js代码如何使用

admin admin 发表于2022-05-28 06:48:37 浏览111 评论0

抢沙发发表评论

js如何修改iframe 中元素的属性


网页加载的时候,iframe里面的还没加载完当然就更改不了
1.纯js的
《!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN“ “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“》
《html xmlns=“http://www.w3.org/1999/xhtml“》
《head》
《meta http-equiv=“Content-Type“ content=“text/html; charset=utf-8“ /》
《title》无标题文档《/title》
《script language=“javascript“》
function c(){
var a;
try{
if (document.all){
a = document.frames[“a“].document;

}else{
a = document.getElementById(“a“).contentDocument;
}
var b = a.getElementsByName(“b“);
b.disabled = true;
clearInterval(d);
}
catch(ex){

}
}
《/script》
《/head》
《body》
《iframe id=“a“ src=“b.html“ onload=“c();“》《/iframe》
《/body》
《/html》
2.使用jQuery框架的,建议使用,封装了js,操作DOM等等非常方便
《!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN“ “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“》
《html xmlns=“http://www.w3.org/1999/xhtml“》
《head》
《meta http-equiv=“Content-Type“ content=“text/html; charset=utf-8“ /》
《title》无标题文档《/title》
《script language=“javascript“ src=“/js/jquery-1.4.4.js“ type=“text/javascript“》《/script》
《script language=“javascript“ type=“text/javascript“》
《!--//
$(document).ready(function(){
if ($.browser.msie){
$(’#a’).ready(function(){
$(window.frames[“a“].document).find(“input“).attr(“disabled“,“disabled“);
});
}
else{
$(’#a’).load(function(){
$(’#a’).contents().find(“input“).attr(“disabled“,“disabled“);
});
}
});
//--》
《/script》
《/head》
《body》
《iframe id=“a“ name=“a“ src=“iframechild.html“》《/iframe》
《/body》
《/html》

b.html
《!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN“ “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“》
《html xmlns=“http://www.w3.org/1999/xhtml“》
《head》
《meta http-equiv=“Content-Type“ content=“text/html; charset=utf-8“ /》
《title》无标题文档《/title》
《/head》

《body》
《form name=“cform“》《input type=“text“ name=“b“ /》《/form》
《/body》
《/html》

js代码如何使用


js代码是动态脚本语句,是弥补静态显示的不足。通过js可以操作dom节点,动态的修改dom节点的内容

比如

《body》
   《input type=’text’ id=’ipt’ value=’111’/》
《/body》
《script》
   document.getElementById(’ipt’).value=’222’;//这里使用js动态修改了input的value值。
《/script》

jsp 好吗 现在还有人用吗


我也刚入门半年多 感觉JSP入门比较慢 使用情况寒假里搜索了一下大概就是 由于成本比较高 所以所见比较少 而一些大型网站有不少是用JSP做的 说是JSP安全级别比较高 也有说漏洞比较多的 有说将来主流可定是EJB等等 各各软件各有千秋 个人感觉投入比较大
-属性