本文介绍了cssRules在FireFox 1.5中不再适用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个基于HTMLArea项目的WYSIWYG编辑器,它使用样式表的 cssRules对象来添加/更新 表格单元格的样式表规则。自从我升级到FireFox 1.5后,我在尝试访问cssRules对象时收到以下 错误消息: 访问受限制的URI被拒绝 我试图执行的代码如下: var currStyleSheet = editor._doc.styleSheets [0]; var currRules = currStyleSheet.cssRules; var tdIndex = currRules.length; for(i = 0; i< currRules.length; i ++) { if(currStyleSheet.cssRules.item(i).type == 1){ //如果是样式规则 var currRule = currRules.item(i) if(currRule.selectorText.toLowerCase()==" td"){ tdIndex = i; } } } 此代码只是寻找TD元素的任何规则。如果FireFox导致这个错误导致 发生了什么变化和/或发生了什么变化,我将损失。它在之前版本的FireFox中运行良好。我试图访问样式表的 文档位于 IFRAME中,这是我认为导致问题的原因。谢谢。 I have a WYSIWYG editor based on the HTMLArea project that uses thecssRules object of a stylesheet to add/update stylesheet rules fortable cells. Ever since I upgraded to FireFox 1.5, I get the followingerror message when trying to access the cssRules object: "Access to restricted URI denied" The code I am trying to execute looks like this: var currStyleSheet = editor._doc.styleSheets[0];var currRules = currStyleSheet.cssRules;var tdIndex = currRules.length;for(i = 0; i < currRules.length; i++) {if(currStyleSheet.cssRules.item(i).type == 1) {//if it is a style rulevar currRule = currRules.item(i)if (currRule.selectorText.toLowerCase() == "td") {tdIndex = i;}} } This code is simply looking for any rules for TD elements. I am at aloss as to what is going on and/or what changed if FireFox to causethis error. It worked fine in previous releases of FireFox. Thedocument that I am trying to access the stylesheet for is within anIFRAME, which is what I believe is causing the problem. Thanks. 推荐答案 错误信息是否没有命名导致错误的确切行号? 是哪一行,尝试访问 editor._doc 或尝试访问 currStyleSheet.cssRules 带有脚本的HTML文档的URL是什么,什么是 的网址是iframe?由于错误消息显示访问限制URI被拒绝 看到URI可能会有所帮助。 - Martin Honnen http://JavaScript.FAQTs.com/ 你还遇到这个问题吗?你有一个带例子的URL吗? - Martin Honnen http://JavaScript.FAQTs.com/ 这篇关于cssRules在FireFox 1.5中不再适用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 08:39