chrome中的content script脚本文件

打开chrome的devtools工具,sources下有一个Content script:

1 chrome插件开发过程中难免会遇到使用content script来操作页面的dom,在chrome官方文档中有关于content script的一些说明:

“Content scripts are JavaScript files that run in the context of web pages. By using the standard Document Object Model (DOM), they can read details of the web pages the browser visits, or make changes to them.”

由于content script运行在称之为“隔离环境”的特殊环境中,虽然它能够对页面的dom进行直接访问及操作,但对页面上的js变量及函数却无法进行访问,反过来也是如此,content_script处在一个闭环的空间中,与世隔绝。

 

可参考:

http://gmeiz.me/blog/chrome%E6%89%A9%E5%B1%95%E5%BC%80%E5%8F%91%E6%9D%82%E8%AE%B0-content-script%E7%94%A8%E6%B3%95

http://open.chrome.360.cn/html/dev_content_scripts.html

posted @ 2014-04-13 22:53  simonbaker  阅读(1509)  评论(0编辑  收藏  举报