IE Buttons JavaScript Interaction (like Greasemonkey for FF)

  • Thread starter Thread starter 9icj4u613jeqrx8
  • Start date Start date
9

9icj4u613jeqrx8

Hi,

I need some help with IE browser programming (in .NET).

I'm trying to add a button to the IE toolbar, and on the click of the
button open a popup window with a remote URL. Secondly, I'm trying to
highlight certain predefined words on particular web sites through the
IE plugin itself.

To add an IE button, I've found this neat article:
http://www.codeproject.com/useritems/CorKatIEExtension.asp

But I'm stuck with two things:

1. How to open a popup window (IE instance) on the click of the
button? The article above doesn't mention it.

2. How can I include some JavaScript code in the "plugin", so that it
executes some JavaScript code on particular pages (much like the
Greasemonkey extension for Firefox)? I'm aware of a few such tools for
IE (Turnabout, G4IE etc.) which provide Greasemonkey-like
functionality, but I want to build a stand-alone plugin (without any
additional downloads) for the end-user.

Please suggest some ideas on how I can resolve the above two issues.

Thanks in advance!
 
I'm trying to add a button to the IE toolbar, and on the click of the
button open a popup window with a remote URL. Secondly, I'm trying to
highlight certain predefined words on particular web sites through the
IE plugin itself.

To add an IE button, I've found this neat article:
http://www.codeproject.com/useritems/CorKatIEExtension.asp

But I'm stuck with two things:

1. How to open a popup window (IE instance) on the click of the
button? The article above doesn't mention it.

The article shows a button that runs an executable when clicked. An IE
toolbar button may also be backed by script, or by a COM object. For
details, see

http://msdn2.microsoft.com/en-us/library/aa753588.aspx

In all three cases, you can create a new standalone instance of IE with
CoCreateInstance(CLSID_InternetExplorer) (in case of JavaScript, that
would be new ActiveX("InternetExplorer.Application"); in case of
VBScript, CreateObject("InternetExplorer.Application") ). There should
be a .NET equivalent, but I don't know what it is off the top of my
head.

A script can also use window.open, just like the script on the page
would.

A COM object can use an equivalent to window.open. It also can call
IWebBrowser2::Navigate with navOpenInNewWindow flag.
2. How can I include some JavaScript code in the "plugin", so that it
executes some JavaScript code on particular pages (much like the
Greasemonkey extension for Firefox)?

When you create a toolbar button, you have an option of setting it up to
run a piece of JavaScript when clicked. Is this what you have in mind?

If you want your plugin to work automatically without user intervention,
then toolbar button is a wrong type of extension to implement. You want
a browser helper object (BHO):

http://msdn2.microsoft.com/en-us/library/bb250436.aspx

BHOs can only be implemented as COM components, you can't write one with
script.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 
Thanks for your suggestions Igor! Very informative!

As part of a project, I'm already looking into building a simple BHO
which executes some JavaScript in the background for certain web
pages. I'm trying to execute the JavaScript in the BHO using the
browsers instance object and using the execScript method for the
object. JavaScript and other DOM access works fine this way, but if I
try to use Ajax (xmlhttp) from the JavaScript, it fails (permission
denied) for obvious cross-domain scripting reasons. I was wondering if
there's any other way (besides writing the Ajax-related code as
managed code in C#) to execute Ajax from within the JavaScript code
that I run using execScript? Please suggest.

Thanks again!
 
Back
Top