用A页面去定义Iframe中B页面的一个参数如下:
A页面中有:<link rel="stylesheet" type="text/css" href="<%= lanxi.resu_a_k.ListViewValue %>">
去定义页面的样式
怎样在IFRAME中B页面都可以用这个样式呢?
虚心求教~!
A页面中有:<link rel="stylesheet" type="text/css" href="<%= lanxi.resu_a_k.ListViewValue %>">
去定义页面的样式
怎样在IFRAME中B页面都可以用这个样式呢?
虚心求教~!
测试如下:
3个文件:a.html b.html test.cssa.html<html>
<head>
<title></title>
<link id="link1" rel="stylesheet" type="text/css" href="test.css">
<script>
window.onload = function(){
var newlink = document.frames["iframe1"].document.createElement("link");
newlink.setAttribute("rel", "stylesheet");
newlink.setAttribute("type", "text/css");
newlink.setAttribute("href", document.getElementById("link1").href); document.frames["iframe1"].document.body.appendChild(newlink);
}
</script>
</head><body>
<div>测试文字</div>
<iframe name="iframe1" src="b.html"></iframe>
</body>
</html>b.html
<div>测试文字</div>
test.cssdiv{
color:red;
font-size:36px;
}
我用动态方法去加载CSS样式的
<link rel="stylesheet" type="text/css" href=" <%= lanxi.resu_a_k.ListViewValue %>">
所以不能在页面一打开就window.onload ~!要等我点击后过能吧~!怎么改呢?
<HEAD>
<TITLE> Test Page </TITLE>
</HEAD>
<BODY> <script>function cSrc(url)
{
var ifm=document.getElementById( "test")
ifm.src=url;
}
function aaa(){
var newlink = document.frames["test"].document.createElement("link");
var ifm=document.getElementById( "test")
newlink.setAttribute("rel", "stylesheet");
newlink.setAttribute("type", "text/css");
newlink.setAttribute("href", document.getElementById("link1").href);
document.frames["test"].document.body.appendChild(newlink);
ifm.src=url;
}
</script><link id="link1" rel="stylesheet" type="text/css" href="test.css"><div>测试文字</div>
<a href="#" onClick="document.getElementById('test').src='http://WWW.163.com'">asdf</a>
<a href="#" onclick= "aaa('b.html')"> b</a>
<iframe name="test" src="b.html" ></iframe>
</BODY>
</HTML>