none
Register to InternetExplorer events RRS feed

  • Question

  • Hi All,

    We have a requirement in where we need to open a InternetExplorer instance on click of button in Outlook. Also if one such instance of InternetExplorer (opened from Outlook) is already opened, user will not be allowed to open a new instance of InternetExplorer from Outlook. Below are the steps that we did to achieve this:

    1. Set a Boolean variable (isIElaunched) to false on plugin start up.
    2. When the outlook button is clicked, launch a instance of InternetExplorer and set the Boolean variable (isIElaunched) to true.
    3. Register to Quit event for the instance of InternetExplorer just launched.
    4. On quit of the browser, set the Boolean variable to false again.

    Issue: The registered browser event is working intermittently when testing from plugin. But when using the same code snippet from a console application, the event is working fine. Below is the code snippet what we have used. Can someone advice where I am going wrong.

    Additionally, when using InternetExplorer.Navigate function, it is immediately invoking the Quit event.

    public void onClickOutlookBtn(Office.IRibbonControl control)
    {
        string postParams = "param1=param1Val&param2=param2Val";
        string PostHeaders = "Content-Type: application/x-www-form-urlencoded";
        string url = "a sample web url";
        InternetExplorer ieObject = new InternetExplorer();
        ((DWebBrowserEvents_Event)ieObject).Quit += new DWebBrowserEvents_QuitEventHandler(Quit);
         ieObject.Visible = true;
         isIElaunched = true;
         ieObject.Navigate(url, null, null, post, PostHeaders);
    }

    public void Quit(ref bool Cancel)
    {
        System.Windows.Forms.MessageBox.Show("IE CLOSED");
        isIELaunched = false;

    }



    • Edited by NikhileshJ Monday, July 11, 2016 4:43 PM Change in observation
    Monday, July 11, 2016 4:20 PM

All replies

  • >>> The registered browser event is working intermittently when testing from plugin. But when using the same code snippet from a console application, the event is working fine. Below is the code 

    snippet what we have used. Can someone advice where I am going wrong.<<<

    According to your description, I have made a sample to try to reproduce this issue, but I find there are some syntax errorr, I have fixed then run this sample, unfortunately, I can't reproduce it.

    Add Ribbon(XML) named "RibbonIEXml"
    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
      <ribbon>
        <tabs>
          <tab idMso="TabAddIns">
            <group id="MyGroup"
                   label="My Group">
              <button id="btnIE" label="Internet Explorer" onAction="onClickOutlookBtn"/>
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    Callback code:
    bool isIELaunched = false;
    public void onClickOutlookBtn(Office.IRibbonControl control)
    {
        string postParams = "param1=param1Val&param2=param2Val";
        string postHeaders = "Content-Type: application/x-www-form-urlencoded";
        string url = "https://www.google.com.sg/?gfe_rd=cr&ei=11SEV9r4K-HN8ge55IywCA";
        InternetExplorer ieObject = new InternetExplorer();
        ((DWebBrowserEvents_Event)ieObject).Quit += new DWebBrowserEvents_QuitEventHandler(Quit);
        ieObject.Visible = true;
        isIELaunched = true;
        ieObject.Navigate(url, null, null, postParams, postHeaders);
    }
    public void Quit(ref bool Cancel)
    {
        System.Windows.Forms.MessageBox.Show("IE CLOSED");
        isIELaunched = false;
    }

    Tuesday, July 12, 2016 3:04 AM
  • Hi,

    Thanks for your reply. The issue was with web application that we were using. For blank page / google's website it is working as expected.

    • Proposed as answer by David_JunFeng Wednesday, July 20, 2016 2:31 PM
    Wednesday, July 13, 2016 8:23 PM
  • >>>The issue was with web application that we were using. For blank page / google's website it is working as expected.

    I am glad to hear that you have found this root cause, have you resolved this issue.

    In addition you could display the request headers that are sent to the server.

    For more information, click here to refer about Using Windows Internet Explorer Developer Tools Network Capture

    Friday, July 15, 2016 5:08 AM