惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Engineering at Meta
Engineering at Meta
量子位
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
月光博客
月光博客
A
About on SuperTechFans
博客园 - 聂微东
Spread Privacy
Spread Privacy
B
Blog
NISL@THU
NISL@THU
小众软件
小众软件
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
T
Threatpost
Stack Overflow Blog
Stack Overflow Blog
博客园 - 叶小钗
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
P
Privacy & Cybersecurity Law Blog
C
Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Palo Alto Networks Blog
C
Check Point Blog
O
OpenAI News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
IT之家
IT之家
T
Threat Research - Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Know Your Adversary
Know Your Adversary
T
The Exploit Database - CXSecurity.com
N
News and Events Feed by Topic
P
Privacy International News Feed
B
Blog RSS Feed
Google DeepMind News
Google DeepMind News
H
Heimdal Security Blog
Martin Fowler
Martin Fowler
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
V
Vulnerabilities – Threatpost
博客园 - 司徒正美
C
CERT Recently Published Vulnerability Notes
H
Hacker News: Front Page
PCI Perspectives
PCI Perspectives

博客园 - Go_Rush

发一个python写的多线程 代理服务器 抓取,保存,验证程序,希望喜欢python的朋友和我一起完善它 根据生日或者日期 获取 生肖和星座的 JavaScript代码 身份证号码前六位所代表的省,市,区, 以及地区编码下载 15位, 18位的身份证号码的验证函数.以及根据身份证取省份,生日,性别 一个友好的.改善的 Object.prototype.toString的实现 发两个小东西,ASP/PHP 学习工具。 用JavaScript写的 怎样写一个通用的JavaScript效果库!(2/2) 怎样写一个通用的JavaScript效果库!(1/2) 自己写的几个高效,简洁的字符处理函数 无语,javascript居然支持中文(unicode)编程! ie 处理 gif动画 的onload 事件的一个 bug 讲两件事:1.this指针的用法小探. 2.ie的attachEvent和firefox的addEventListener在事件处理上的区别 总结两个Javascript的哈稀对象的一些编程技巧 使用prototype.js 的时候应该特别注意的几个问题. 再论怎么有效利用浏览器缓存之------怎么避免浏览器缓存静态文件. RE:对博客园URL的一些调整建议, 二级域名不利于客户端浏览器缓存 深入聊聊Array的sort方法的使用技巧.详细点评protype.js中的sortBy方法 由 element.appendChild(newNode) ,谈开去, 分享几个并不常见的Dom操作技巧给大家 JavaScript写作技巧,函数A中调用函数B, 怎样在函数B中写代码中断函数A的运行?
在项目中玩了把addRule,结果差点被它玩死。附 addRule在firefox下的兼容写法
Go_Rush · 2006-11-29 · via 博客园 - Go_Rush

现在用脚本控制 html 元素样式的方法真的很多很多。
对单个元素可以直接 element.style.display=......修改一个样式,也可以 element.className=...修改它的多个样式。
对于多个元素修改样式可以用脚本直接 import  css文件。
目前项目中有这么一个需求。 要求改变某 div下所有子孙结点的样式,但不改变div本身样式。
我当时想都没有想就留下了一下代码:


<style>
  span
{background-color:blue;}
  input
{background-color:gray}
  button
{margin-top:70px;width:50px}
</style><!--  by Go_Rush(阿舜) from http://ashun.cnblogs.com/ ---><div id="a1">
divdiv
  
<span>
    spanspan
    
<h2>ttttt</h2>
</span>
    
<input>
</div><button onclick='document.styleSheets[0].addRule("#a1 *","background-color:red")'></button>

 这段代码一直工作得很好,直到有一天我同事告诉我,我的模块让他的浏览器崩溃了。

我打着手电筒,拿着放大镜在近两千多行的代码中找了又找。.
根本找不到问题出在哪里,而且当时对于上面的代码丝毫没有怀疑过。
我们div 的id 是从数据库里面直接读取的,为数字类型,比如 <div id="345"></div>等等。
对于id 能取什么字符,我以前在 ie6和 ff1.5中测试过,


<div id="阿舜"></div>
<div id="???"></div>
<div  id="-1"></div>

这样的id设置,都可以用 
document.getElementById("阿舜")
document.getElementById("???"),
document.getElementById("-1"),

读出来不会有问题,更何况是纯数字呢.

最后经过反复调试,找到这个罪魁祸首 addRule.
document.styleSheets[0].addRule("#a1 *","background-color:red")
document.styleSheets[0].addRule("#123 *","background-color:red")
都没有任何问题

下面这行代码却会让ie死掉. 内存和虚拟内存一直暴涨,我512的内存,一下子xp就提示虚拟内存不够。
document.styleSheets[0].addRule("#-1 *","background-color:red");

同样,在 ff1.5中,将导致函数出错,但不会崩溃。

总结:
   1。 ie,ff对 id 的取值相当宽容,id几乎可以是任何字符,中文,英文,字母,数字,负数,特殊字符
   2。 但是 addRule 函数中, id为负数时,在 ie和ff都会失败,而且ie会崩溃。

附:
  addRule在 ff中的兼容写法

firefox下的addRule---(insertRule)