سؤال

I'd like to write an IE add-on that allows me to find a phone number on a web-page and replace it with a clickable link, that initiates a call. It should be very similar to what the Skype plugin does.

I'm using managed C# 4.0 and I already can register a Browser Helper Object and attach to the DocumentComplete event.

My question is: What is the most efficient and recommended way to identify a phone-number, given that I have an HTMLDocument inside the DocumentComplete event?

هل كانت مفيدة؟

المحلول

use document.all to get all elements (IHTMLDocument2::get_all in C++).

enumerate the element collection using for each (use IHTMLElementCollection::get__newEnum if you switch to C++).

QI for IHTMLDOMNode for each element, then look for top level text nodes under the element node.

If performance is still slow, your bottleneck is probably related to CLR, switch to C++.

Suggested reading: IE + JavaScript Performance Recommendations - Part 1

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top