Shoutbox

[help] InternetExplorer Object events... - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [help] InternetExplorer Object events... (/showthread.php?tid=93546)

[help] InternetExplorer Object events... by whiz on 01-15-2010 at 09:06 PM

Reference: http://msdn.microsoft.com/en-us/library/aa752084.aspx

Methods can be accessed through Browser.Method() and properties can be accessed through Browser.Property.  My question is: can you get to events?  Is it possible to call a function when navigation starts, or finishes?

Oh, and is it possible to see what's in the history?  I know I can keep track of it in an array or something, but is there a function for it?


RE: [help] InternetExplorer Object events... by roflmao456 on 01-16-2010 at 03:45 AM

yeah. pretty similar to how i do WMP events in WLMini Music Player.

set a variable to the interface and then do:

code:
function variablename::eventname(parameters){

}

RE: [help] InternetExplorer Object events... by whiz on 01-16-2010 at 11:17 AM

js code:
var Window = MsgPlus.CreateWnd("Windows.xml", "WndBrowser", 0);
var BrowserObj = Window.Browser_GetInterface("Browser");
BrowserObj.GoHome();
function BrowserObj::BeforeNavigate()
{
    // do loading stuff
}
code:
Message in Script Debug
Script is starting
Error: 'BrowserObj' is undefined (code: -2146823279)
       File: Browser.js. Line: 4.
Script has failed to start
It seems that none of the events work.  Any ideas?

Edit: tried with variables, still didn't work.
js code:
function BrowserObj::BeforeNavigate(pDisp, url, Flags, TargetFrameName, PostData, Headers, Cancel)

RE: RE: [help] InternetExplorer Object events... by felipEx on 01-16-2010 at 10:15 PM

quote:
Originally posted by whiz
It seems that none of the events work.  Any ideas?

this should do the trick :)
JScript code:
var Wnd = MsgPlus.CreateWnd("InterfaceTest.xml", "WndTest");
var browser = Wnd.Browser_GetInterface("browser");

(function(Browser) {

    function Browser::DocumentComplete(){
    }

    function Browser::NavigateComplete2(pDisp, URL){
        Debug.Trace(URL);
    }

    function Browser::TitleChange(sText){
    }

    function Browser::DownloadBegin(){
    }
   
    function Browser::ProgressChange(nProgress, nProgressMax){
    }

})(browser);

browser.Navigate2("http://www.google.com");
// browser.GoHome();
As for keeping track of the history list you could manually do it using the appropriate event ;-)
RE: [help] InternetExplorer Object events... by whiz on 01-17-2010 at 01:37 PM

Works great, thanks!

Next question...  the Browser::NavigateComplete() function is fired when pages in frames are loaded, and I am using that function to set the loaded page's address in the address bar.  Is there a way to filter it between main pages and framed pages?


RE: [help] InternetExplorer Object events... by matty on 01-18-2010 at 04:27 PM

Have you looked at the MSDN page? It states that there are 2 parameters for the function... first one being the web browser object second being the URL...

http://msdn.microsoft.com/en-us/library/aa768332%28VS.85%29.aspx


RE: [help] InternetExplorer Object events... by whiz on 01-18-2010 at 05:15 PM

quote:
Originally posted by matty
Have you looked at the MSDN page? It states that there are 2 parameters for the function... first one being the web browser object second being the URL...
Surely the object parameter will just contain the browser object, regardless of frames?

Edit: ah, hold on...
quote:
Originally posted by MSDN
pDisp
        Object that evaluates to the top-level or frame WebBrowser object corresponding to the event.
Fair enough.

Ok, another question.  The Browser::BeforeNavigate() and Browser::BeforeNavigate2() functions don't get called, and nor does the Browser::NewWindow(), Browser::NewWindow2() and Browser::NewWindow3() functions.  Any possible reasons why?  Are they not supported?
RE: [help] InternetExplorer Object events... by matty on 01-18-2010 at 05:47 PM

No the second parameter is the URL. A frame is going to have a different URL than the main page...


RE: [help] InternetExplorer Object events... by whiz on 01-18-2010 at 05:52 PM

quote:
Originally posted by matty
No the second parameter is the URL. A frame is going to have a different URL than the main page...
Yes...  but how do I tell the difference between a main page and a frame page, then?
RE: [help] InternetExplorer Object events... by matty on 01-18-2010 at 05:54 PM

Can you not get the url from the browser object?


RE: [help] InternetExplorer Object events... by whiz on 01-18-2010 at 07:14 PM

Yeah, but how can the script tell the difference between the URL of a main page and the URL of a framed page?


RE: [help] InternetExplorer Object events... by matty on 01-18-2010 at 07:21 PM

You can't not without reading the code of the page I would assume. If you just need to show the URL simply do browser.LocationURL


RE: [help] InternetExplorer Object events... by whiz on 01-18-2010 at 07:48 PM

quote:
Originally posted by matty
You can't not without reading the code of the page I would assume. If you just need to show the URL simply do browser.LocationURL
Oh yeah, should have thought of that.  :P

Ok, but any idea why the BeforeNavigate and NewWindow functions don't work (original post here)?