在座有人有开发IE扩展的经验吗?这将包括代码示例,或链接到好的示例,或关于流程的文档,或任何东西。
我真的很想这么做,但我碰到了一堵巨大的墙,里面有糟糕的文档、糟糕的代码/示例代码/缺乏它们。你能提供的任何帮助/资源都将不胜感激。
具体来说,我想从如何从IE扩展中访问/操作DOM开始。
编辑,甚至更多的细节:
理想情况下,我想种植一个工具栏按钮,当点击时,弹出一个菜单,其中包含到外部网站的链接。我还想根据某些条件访问DOM并在页面上植入JavaScript。
在IE扩展中保存信息的最好方法是什么?在Firefox/Chrome/大多数现代浏览器中,你使用window。localStorage,但显然在IE8/IE7中,这不是一个选项。也许是SQLite DB之类的?可以假设。net 4.0将安装在用户的计算机上吗?
我不想使用Spice IE,因为我想构建一个与IE9兼容的IE。我也为这个问题添加了c++标签,因为如果用c++构建一个更好的话,我可以这样做。
The state for IE extensions is actually pretty sad. You have the old model of IE5 Browser Helper Object (yeah, those infamous BHOs that everyone liked to block back in the day), toolbars and the new accelerators for IE.
Even then, compatibility will break sometimes. I used to maintain an extension for IE6 that broke with IE7, so there are some things that have changed. For the most part, as far as I know (I haven't touch BHOs in years) you still need to code them using Active Template Libraries (kind of like an STL for Microsoft's COM) and well as such is only for C++.
You could do COM Interop with C# and get away with doing it in C# but its probably going to be too hard for what it is worth.
Anyway, if you are interested in coding your own extension for IE (which is plausible if you want to have your extensions available in all major browsers) here are the official Microsoft Resources.
http://msdn.microsoft.com/en-us/library/aa753587 (v = vs.85) . aspx
至于IE8中新增的加速器,你可以看看这个。
http://msdn.microsoft.com/en-us/library/cc289775 (v = vs.85) . aspx
我同意它的文档很糟糕,api也很过时。不过,我希望这能有所帮助。
EDIT: I guess I can throw one last source of information here. I was looking through my notes of back when I was working on BHOs. And this is the article that got me started with them. It is kind of old, but has a good explanation of the ATL interfaces that you will be using when working with IE BHOs (IObjectWithSite for example). I think it is pretty well explained and helped me a lot back then.
http://msdn.microsoft.com/en-us/library/bb250436.aspx
I also checked the example that GregC posted. It does work with at least IE8, and it is compatible with VS 2010, so if you want to do C# you can get started there and take a look at Jon Skeet's Book. (C# in Depth 2nd edition) Chapter 13 has a good deal of information about the new features in C# 4 that you can use to make the interaction with COM nicer. (I would still recommend you doing your addin in C++)