我想用javascript给下面frame中的id为RDBiframe的scr赋值,可是不成功,如果解决呢?
我在<body>下面,frame之后这样写,但不成功:
<script>
document.getElementById('RDBiframe').src='http://www.baidu.com';
</script>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<frameset rows="*" cols="0,*" framespacing="0" frameborder="no" border="0">
<FRAME src="" name="clicklog">
<frameset rows="142,*" frameborder="NO" border="0" framespacing="0">
<frame scr="" name="searchbar" scrolling="NO" noresize>
<frame id="RDBiframe" name="RDBiframe" SRC="">
</frameset>
</frameset>
<noframes>
<body>
</noframes>
</html>
我在<body>下面,frame之后这样写,但不成功:
<script>
document.getElementById('RDBiframe').src='http://www.baidu.com';
</script>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<frameset rows="*" cols="0,*" framespacing="0" frameborder="no" border="0">
<FRAME src="" name="clicklog">
<frameset rows="142,*" frameborder="NO" border="0" framespacing="0">
<frame scr="" name="searchbar" scrolling="NO" noresize>
<frame id="RDBiframe" name="RDBiframe" SRC="">
</frameset>
</frameset>
<noframes>
<body>
</noframes>
</html>
或者JQuery的$(document).ready(function(){..})中
window.onload=function(){
document.getElementById('RDBiframe').src='http://www.baidu.com';
}
</script>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="javascript" type="text/javascript">
window.onload = function () {
document.getElementById('RDBiframe').src = 'http://www.baidu.com';
}
</script>
</head>
<frameset rows="*" cols="0,*" framespacing="0" frameborder="no" border="0">
<frame src="" name="clicklog" />
<frameset rows="142,*" frameborder="NO" border="0" framespacing="0">
<frame src="" name="searchbar" scrolling="NO" noresize />
<frame id="RDBiframe" name="RDBiframe" src="" />
</frameset>
</frameset>
<body>
<noframes>
</noframes>
</body>
</html>
<frame id="RDBiframe" name="RDBiframe" src="" />RDBiframe.document.location = "url"
或者不用document 楼主可以试试