Tuesday, December 21, 2004

MSHTML Hosting - Calling JavaScript From Host

I don't know how often someone would want to call a JavaScript (JS) function in the WebBrowser control from the host application. Since the host can control many, if not more, aspects of the HTML content externally using IDocHostUIHandler or the MSHTML DOM interfaces, it seems unnecessary to implement a method in JS and call that method from the host. But, if you need to for some reason, here's how to do it:

IHTMLDocument* pHTMLDoc = /* however you can get the IHTMLDocument */

DISPID idMethod = 0;
OLECHAR FAR* sMethod = L"DoSomething";
IDispatch* pScript = 0;
HRESULT hr = pScript->GetIDsOfNames(IID_NULL, &sMethod, 1, LOCALE_SYSTEM_DEFAULT,
if (SUCCEEDED(hr)) {
  // invoke assuming no method parameters
  DISPPARAMS dpNoArgs = {NULL, NULL, 0, 0};
                       &dpNoArgs, NULL, NULL, NULL);

Notice we are using the IHTMLDocument interface, not the more often used IHTMLDocument2 interface. Also note that I am assuming no arguments are passed to the JS method. Check out IDispatch::Invoke for more information on calling a method with arguments. CodeProject has a few nice articles as well.


At 12:17 PM, Anonymous Anonymous said...

this is what I am looking for, but can you translate this to c#? That would help me out a lot.


At 12:02 PM, Anonymous Anonymous said...

IHTMLDocument doc1 = (IHTMLDocument)axWebBrowser1.Document ;
HTMLWindow2 iHtmlWindow2 = (HTMLWindow2) doc1.Script ;
iHtmlWindow2.execScript( "functionName(param1);" , "javascript" ) ;

At 4:37 PM, Anonymous Anonymous said...


i got two method.

1) IHTMLDocument
2) iHtmlWindow2.execScript

At 7:14 PM, Blogger Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.

At 6:39 AM, Anonymous online writing service said...

I hope that this issue will be developing in future.

At 6:59 AM, Blogger polo shirts said...

History of polo ralph lauren. Polo fashions had its humble beginnings in 1968 when tie salesman Ralph Lauren gave it a kick start. By 1969 he had a boutique polo ralph lauren factory stores within the Manhattan department store Bloomingdale's. ... Brands and luxury standard. Since Ralph Lauren's first brand, Polo Ralph Lauren, was launched, the company has expanded to include a variety of luxury brands such as Polo Golf, Polo Denim, Polo Sport. You can buy cheap Ralph Lauren Clothing at Ralph Lauren outlet.Also We provide polo shirts
Ralph Lauren polo shirt, 50% OFF! polo ralph lauren outlet online is your best choice!In 2006, polo ralph lauren outlet became the first designer in Wimbledon's 133-year history to create official uniforms for the tournament. As part of this year's event, which starts next week, polo ralph lauren sale will introduces the first ... determination to maintain and enhance the values for which our two brands are famous throughout the world. The rugby ralph lauren brand brings to Wimbledon the look of timeless elegance, drawing on our rich history and traditions

At 7:39 AM, Blogger Tory Burch Shoes said...

Dsquared kudjisojihw
dsquared store
dsquared jeans
dsquared jeans men
dsquared clothing
dsquared t shirts

At 2:44 AM, Blogger 2011bagnews said...

The first form of protection device was Oakley Jawbone Review made of walrus ivory with just bvvmcxy0vb a slit through which they could pierce. From utilitarian Oakley sunglasses of about half a century ago to the present fashionable ones, Oil Rigs Oakley there have been a long story of development and Oil Rig Oakley Sunglasses have played a key role in that. For the real dare devil, you need a pair of rectangular frame Oakley sunglasses. These Discount Oakley Oil Rig Sunglasses are fun and very trendy. They will look good on so many different face shapes, no matter female or male. If you want a pair of Oakley Frogskin Sunglasses that will really make you stand out from the rest of the crowd, then you need to get a pair of these! You will look cool and very stylish.When we think of white shades, we tend to think of the West Coast, Oakley Dispatch so why not bring that style wherever you live by wearing a pair of white Oakley O Frame . They are sexy and stylish, and still are very durable. Oakley O Frame Goggle These shades were developed specially for pilots to protect their eyes from dangerous Oakley O Frame Goggle rays of the sun during their flight missions. There are a lot of people who are enamored by these Oakley O Frame Snow and want to possess a pair of them.

At 10:28 PM, Anonymous Anonymous said...

In reality, almost almost all colors enables you vbnfuyt to brush or perhaps tint prescribed oakley frogskins . Generally, cheap Oakley sunglasses virtual test can become fallen directly into several sorts and different online vendors could have their distinct ones. oakley frogskins can be abbreviated directly into "try-on" or perhaps "virtual try-on". In any manner, one can easily open this kind of item when he desires to choose his / her beloved low-cost oakley jawbone . Another extremely professional low-cost Oakley sunglasses virtual test is founded on the info of peoples' faces and also heads. Such test oakley flak jacket will be professional and also complicated, yet very correct. Some blanks concerning people's face can be filled, like the length, size, height with the face, brow, and a great many other oakley radar

At 2:42 AM, Anonymous Anonymous said...

As it can certainly always be reported folks stars zjfgksy benefit from getting into oakley frogskins in the personalized variations. Along with these kinds of patterns are generally individual for the children. As a result, while the idea happens to the part of fans, these kind of oakley frogskins are set up approximately related to the patterns ones. while correctly as being a happening comes about, that is, your fans in the accurate Oakley place on Oakley sunglasses of these accurate variations. In addition, these are on the way to almost never change his or her style throughout getting into oakley jawbone .Your younger looking girls-oriented Oakley sunglasses, by way of example, are generally actually common. These kind of sun glasses could be the effects involving reduction regular along with cool issues jointly. specifically can be additional, your charges involving oakley flak jacket may be affordable. This has confirmed that will plenty of buyers will probably pay for the children. And thus, oakley radar can invest in just about any shade as well as any kind Oakley sunglasses whenever they similar to. Your component can be the belief that fans will certainly adhere to your patterns in the idols, of course getting into Oakley sunglasses.Normally, duplicate Oakley sunglasses may be affordable.

At 4:05 AM, Anonymous Anonymous said...

Though these kind of oakley frogskins may be fabricated along with uijgfnhm classy, these are cheap. this specific actually is primarily since nearly all while using users involving Oakley sunglasses, your enormous men and women, are not able to spend on deluxe solutions. most of the charges involving oakley frogskins presented from the market are generally underneath one hundred bucks. Your temple involving oakley jawbone can be wide-ranging along with comprehensive involving creative imagination.Zero matter your fine rounded radian or maybe your oblong composition, your temple involving oakley flak jacket can be delicate. The idea not simply calls for your seen elegance into mind, but in addition can be warm for you to don. moreover for you to these kind of, your permanent fixture involving chemical along with shade can be fair. Right now, you may can understand the contact lenses involving individual's oakley radar come to be even bigger along with more substantial. buyers whom place on some Oakley sunglasses using enormous contact lenses declare who's may screen his or her good individuality.

At 12:30 AM, Anonymous Anonymous said...

I need to think fsdjhjhl of a two of oakley frogskins .After an extensive time operating under the sun, I feel rather uncomfortable, and I can have a couple oakley frogskins to support me protect my little brown eyes. I've lived with bad eyesight for virtually every lengthy time period, I need to think of a two of oakley jawbone to support me view items obviously and guard the eye by powerful sun light and extra violet radiations. Subsequently, I want to purchase a couple oakley flak jacket at on-line spectacles shop to be a end reaction to their higher high class and tolerable prices.Make a gross sales pitch and train your people today to consequence your shoppers to obtain your oakley radar . in scenario you could have perfect sales guys and saleswomen, it may improve ones margins. with comparability to help clothes, Oakley sunglasses tend to be attempted oneasily with not significantly more than something like 20 seconds. with scenario people exhibit most of these in check-out companies, your people can sporting them whilst delaying with regard to their change and own it within their buy which shows extra profit.

At 2:25 AM, Anonymous Anonymous said...

They may be Oakley Sunglasses Discount trjgfhpo promoting creating a much more clear perspective. In fact, Cheap Oakley Sunglasses is normally an assortment of Oakley sunglasses and also Oakleys, plus the Oakley sunglasses, which is often quick to the significant classification sun shades, express to supply best quality and also a added brilliant world for your wearers.If you'd prefer normal Oakley Frogskins sporting activities, then you definately should certainly examine acquiring a couple of Oakley Jawbone . These kinds of performer sun shades are usually especially designed for extreme normal water ailments. The particular executive guiding the particular style and design from your Oakley Jawbone Sunglasses is approximately permitting you to notice greater while using the copyrighted Trend 500 and also 500 sun shades. It won't need to value an individual a great provide and also a lower leg to have Oakley sunglasses. when you retailer with a certified on the net supplier, you may receive the least expensive price tag Oakley sunglasses.Once we relate for your significant classification, practically almost every person can feel from your Oakley television set which is often intended to offer you significant decision photo while using the electronic digital sign approach stuck.

At 8:57 PM, Anonymous Anonymous said...

Oakley Sunglasses Discount is visual compromise and the other hfkjtylt is eye protection. In fact, bifocal safety glass is neither a sole nor a strange member in the large family of eyewear products. Prescription Cheap Oakley Sunglasses and prescription goggles are both special types of eyewear that come in a similar design principle.They are designed to shield your eyes from the ultra violet rays of the sun and make it more comfortable for you to see when you're outside. Why do some people want to wear them indoors or at night? In fact, there is no need in wearing them. Maybe they think wearing cool Oakley Frogskins can make them cooler. Other occasions like a social gathering or setting, it is also not suitable to wear Oakley sunglasses. People at the parties will presumably have conversations with others they are interested in.Children will think those Oakley Jawbone are good and can make them more attractive. Of course, now the Oakley sunglasses for children vary a lot in styles that can fit any demand and interest. The Oakley Jawbone Sunglasses of some film characters are also very popular among children. Those Oakley sunglasses are a little expensive than ordinary Oakley sunglasses. Parents should thus let their children do their own choices on what to buy. As sometimes, children will be unsatisfied with the patents' choices. What parents should do only is to consider whether those Oakley sunglasses are durable, comfortable, suitable, etc.It is difficult to approach a new person and say hello to them when someone is wearing dark, cool Oakley sunglasses.

At 3:01 PM, Anonymous Anonymous said...

Nike Air force ones|Nike Air Max Sale|Nike free 3.0|Cheap Nike Frees|Nike Air Max TN|Nike Air Max tailwind 2010|Nike Air Max 2009 Sale|Nike Air Max 95 sale|Nike Air Max 97 sale|Nike Air Max sale

At 2:47 AM, Anonymous Anonymous said...

I am very much pleased with the contents you have mentioned.I wanted to thank you for this great article. I enjoyed every little bit part of it and I will be waiting for the new updates.Thanks. I  am very much impressed from your post.Hosting in India

At 3:22 AM, Anonymous cheapest boots said...

Cheap UGG But she has not heard the voice of Hong Kong and Taiwanese port price cheap price warm praise, alas.

cheapest uggs ever Like adults, adults reason, sitting more than ten hours flying ridiculed, something to eat, a good rest. yt66dyg

cheap uggs for women Stones to do a menu, along with Marley research.

where to buy uggs cheap Dumplings, dan dan noodles, wonton. Enunciate, showing the child addicted to eating.

www.cheapestbootsshop.com Head a little leisurely surprise, "work? Go?"

At 9:39 PM, Blogger qinbincai123 said...

A woman, especially, if she have sjijfj88 the misfortune of knowing anything,
should conceal it as well as she can.
Cheap Hats

Cheap New Era Hats

Wholesale New Era Hats

Cheap NBA Hats

Cheap MLB Hats

Fox Racing Hats

Red Bull Hats

Last Kings Snapback Hats

YMCMB Snapback Hats

Polo Hats

At 4:40 PM, Anonymous pay per head said...

I am thoroughly convinced in this said post. I am currently searching for ways in which I could enhance my knowledge in this said topic you have posted here


Post a Comment

<< Home