如下是一个主page<HTML>
<body>
<iframe src ="demoFramesetLeftFrame.html" name="treeframe" id="treeframe" height="100%" width="19%" frameborder="0">
</iframe>
<iframe src="middle.html" name="middle" id="middle" height="100%" width="10%" frameborder="0">
</iframe>
<iframe src="demoFramesetRightFrame.html" name="basefrm" id="baseframe" height="100%" width="70%" frameborder="0">
</iframe>
</body></HTML>在middle页面中一一段JavaScript代码想要修改treeframe的宽度,代码如下function sidebar() {
var baseFrame = parent.document.getElementById("baseframe");
var leftFrame = parent.document.getElementById("treeframe");
var colIcon = document.getElementById("sbCol");
var expIcon = document.getElementById("sbExp");
if (leftFrame.width == "0%"){
leftFrame.width = "19%";
baseFrame.width = "70%";
colIcon.style.display = "block";
expIcon.style.display = "none";
}
else{
leftFrame.width = "0%";
baseFrame.width = "89%";
colIcon.style.display = "none";
expIcon.style.display = "block";
}
}
}通过chrome的js console观察到如下报错信息
Unsafe JavaScript attempt to access frame with URL file:///E:/not%20SAP%E5%BC%80%E5%8F%91%E4%B9%A6%E7%B1%8D/JavaScript/Treeview/demoFrameset.html from frame with URL file:///E:/not%20SAP%E5%BC%80%E5%8F%91%E4%B9%A6%E7%B1%8D/JavaScript/Treeview/middle.html. Domains, protocols and ports must match.
middle.js:2Uncaught TypeError: Cannot call method 'getElementById' of undefined
望高手赐教,给分40,不甚感谢!
<body>
<iframe src ="demoFramesetLeftFrame.html" name="treeframe" id="treeframe" height="100%" width="19%" frameborder="0">
</iframe>
<iframe src="middle.html" name="middle" id="middle" height="100%" width="10%" frameborder="0">
</iframe>
<iframe src="demoFramesetRightFrame.html" name="basefrm" id="baseframe" height="100%" width="70%" frameborder="0">
</iframe>
</body></HTML>在middle页面中一一段JavaScript代码想要修改treeframe的宽度,代码如下function sidebar() {
var baseFrame = parent.document.getElementById("baseframe");
var leftFrame = parent.document.getElementById("treeframe");
var colIcon = document.getElementById("sbCol");
var expIcon = document.getElementById("sbExp");
if (leftFrame.width == "0%"){
leftFrame.width = "19%";
baseFrame.width = "70%";
colIcon.style.display = "block";
expIcon.style.display = "none";
}
else{
leftFrame.width = "0%";
baseFrame.width = "89%";
colIcon.style.display = "none";
expIcon.style.display = "block";
}
}
}通过chrome的js console观察到如下报错信息
Unsafe JavaScript attempt to access frame with URL file:///E:/not%20SAP%E5%BC%80%E5%8F%91%E4%B9%A6%E7%B1%8D/JavaScript/Treeview/demoFrameset.html from frame with URL file:///E:/not%20SAP%E5%BC%80%E5%8F%91%E4%B9%A6%E7%B1%8D/JavaScript/Treeview/middle.html. Domains, protocols and ports must match.
middle.js:2Uncaught TypeError: Cannot call method 'getElementById' of undefined
望高手赐教,给分40,不甚感谢!
chrome跟opera一样采用高安全性(甚至更甚)
所以要跨frame难度比ff更高在本地跨frame好像是bug... 跨不到的建议你下载一个apache来执行以上代码
window.name='loaded'主page中,
用setInterval判別treeframe的name是否loaded
然後再在主page執行sidebar的內容
运行在本地浏览器的html,你怎么能load本地文件呢,不安全!
解决很多浏览器兼容的问题
chrome的高安全性体现在那些方面了?有没有相关文档?