473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

OnBeforeNavigate2 & DOM ready?

Hello, I am working on a BHO for ie and I'm having some problems.
I have two questions.

1) How can I identify the first request for each website visited on IE (because OnBeforeNavigate2 and other events gets triggered more than once per website).

2) I want to get the website metatags in but how can I know when the DOM is ready and it's not the about:blank or a previous website DOM? (I don't want to wait for images and all that, only the html source).

Here's a little explanation of my code.
In the BHO I use:
Expand|Select|Wrap|Line Numbers
  1.         public int SetSite(object site)
  2.         {
  3.             if (site != null)
  4.             {
  5.                 webBrowser = (WebBrowser)site;
  6.                 webBrowser.BeforeNavigate2+=new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
  7.             }
  8.             else
  9.             {
  10.                 webBrowser.BeforeNavigate2 -= new DWebBrowserEvents2_BeforeNavigate2EventHandler(this.OnBeforeNavigate2);
  11.                 webBrowser = null;
  12.             }
  13.             return 0;
  14.         }
And in that event:
Expand|Select|Wrap|Line Numbers
  1. public void OnBeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
  2.         {
  3.                 document = (HTMLDocument)webBrowser.Document;
  4.                 string URI;
  5.                 if (URL.ToString().ToLower() == "about:blank")
  6.                 {
  7.                     URI = document.url;
  8.                 }
  9.                 else
  10.                 {
  11.                     URI = URL.ToString();
  12.                 }
  13.                 //How can I find if this is the first request to the main URL?
  14.         }
An example of what I am trying to achieve would be:

I open IE, I type google.com, OnBeforeNavigate2 gets triggered for the first time and I get the main url in URI and I do whatever I want with it. Now I want to ignore all the OnBeforeNavigate2 until a new website is visited, could be by typing the url, clicking a link, etc.

I hope someone can help me out with this.

Regards.
Nov 9 '09 #1
0 1601

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gitesh | last post by:
..................... CALL FOR PAPERS ..................... The 2004 International Multiconference in Computer Science and Computer Engineering (18 Joint Int'l Conferences)...
3
by: reclusive monkey | last post by:
I am just starting out with XML. I've been playing with XML and XSLT, very nice indeed. I particularly like the filtering/ordering functions. Anyway, I have started to have a look at scripting, and...
1
by: regisser | last post by:
Is it true that cin,cout, etc are initialized on first use? And that no runtime initialization before main is needed; the first time the object is accessed, it grabs dynamic memory typically like 1K...
3
by: Dan | last post by:
Hello, Am trying to construct a query that'll both compute elapsed time based on certain criteria and sum this up for a subset of records. Sample Data that I'm working with: Row Ev_Time ...
13
by: rbronson1976 | last post by:
Hi all, I have a very simple page that Firefox has problems with: www.absolutejava.com/testing.htm First of all, this page seems to be perfectly valid XHTML Strict. Both the W3C validator as...
20
by: wolftor | last post by:
Would anyone be willing to beta test my application for me and give me some feedback? I can give you feedback in exchange (ie. if there are parts you're interested in knowing how it was done) or I...
26
by: ROSY | last post by:
hello 2 all, where can i get interview question on C & C++. plz give me links it will be so helpful. bye
115
by: Mark Shelor | last post by:
I've encountered a troublesome inconsistency in the C-language Perl extension I've written for CPAN (Digest::SHA). The problem involves the use of a static array within a performance-critical...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as & to be valid. I don't have Firefox my self and don't wont to install it only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.