判断当前页面内嵌有框架??并且可以捕捉到框架的name属性最好是能捕捉到框架的URL,如果捕捉不到URL,能捕捉到框架的name属性也行。再或者是捕捉到框架页内的DOM。
最好是能给出jQuery的写法,感谢!!
最好是能给出jQuery的写法,感谢!!
解决方案 »
- extjs Ext.form.ComboBox问题
- 请教,getElementById('tt2').innerHTML中,如何正常显示带有HTML的值?
- 投票结果 进度条效果
- setTimeout里调用带有event参数的。为啥event不能当参数传啊?
- 给100分继续研究JavaScript正则
- 请教各位高手, 我想在网页里显示些功能,要如何用JaveScript写呢?急!请各位大侠帮帮忙!
- 怎样用DOM的方式把一个XML对象的树节点插入到一个DIV中
- 如何将ocx的事件绑定同javascript联系起来
- 怎样禁止用户在location里直接输入地址,
- 通过鼠标拖动改变二个表格格宽度
- 利用webbrowse如何实现批量打印
- 动态生成div的问题
<script src="js/jquery-1.3.2.js" type="text/javascript"> </script>
<script>
window.onload = function(){
$("iframe,frame").each(
function(){
alert($(this).attr("name"));
alert($(this).attr("src"));
}
)
}
</script>
<iframe name="xx" src=""></iframe>
可以:
$("#frame_id").contents().find("selector")
你好,iframe和主页要是同源,同源是什么意思?URL还是什么?我之前用$("#frame_id").contents().find("selector")来获取,好像不太稳定,有时候出现有时候不出现,是不是就是同源的原因??
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>临时框架对象</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//临时框架对象:
function FrameObj(src){
this.strSrc = src; //前缀URL
this.datestr = new Date()-0+"";
this.strFullSrc = this.strSrc + "?" + this.datestr; //总是获取最新版本的数据
this.strFrameName = "Frame"+this.datestr;
this.CreateFrame();
}
FrameObj.prototype.CreateFrame = function(){
var strsrc = this.strFullSrc||"";
$("body").append('<iframe id="'+this.strFrameName+'" name="'+this.strFrameName+'" scrolling="no" src="'+strsrc+'" frameborder="0" style="display:none;"></iframe>');
return this;
};
FrameObj.prototype.Ready = function(func){
var j_this = $("#"+this.strFrameName+"");
j_this.load(function(){
j_this.contents().find(document).ready(function(){
if($.isFunction(func)){
func(j_this.contents());
}
});
});
return this;
};
FrameObj.prototype.Remove = function(){
$("#"+this.strFrameName+"").remove();
}
//用法:
var newFrame = new FrameObj("index.html");
newFrame.Ready(function(jobj){
alert(jobj.find("body").html());
});
});
</script>
</head><body>
临时框架对象
</body>
</html>
index.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>index</title>
</head><body>
这是index.html的内容
</body>
</html>