I found the similar questions how to call java script function from activex or dll in c# but this is not provide me solution.than i continue my searching finally i got msdn link on this
http://msdn.microsoft.com/en-us/library/ms171712.aspx
To access DOM from a UserControl hosted in Internet Explorer
Create your own custom derived class of the UserControl class. For more information, see How to: Author Composite Controls.
Place the following code inside of your Load event handler for your UserControl:
HtmlDocument doc = null;
private void UserControl1_Load(object sender, EventArgs e)
{
if (this.Site != null)
{
doc = (HtmlDocument)this.Site.GetService(typeof(HtmlDocument));
}
}
Unfortunately I am still unable to get DOM object in my class.I have try to see what i get in this.Site so i put it on a messagebox
MessageBox.Show(this.Site.ToString());
which shows me strange thing that is
System.Windows.Forms.Control+AxSourcingSite
please help me..
Here is a example to call js function from active x:
Type typeIOleObject = "activity control object".GetType().GetInterface("IOleObject", true);
object oleClientSite = typeIOleObject.InvokeMember("GetClientSite",
BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public,
null,
control,
null);
IOleClientSite oleClientSiteoleClientSite2 = oleClientSite as IOleClientSite;
IOleContainer pObj;
oleClientSite2.GetContainer(out pObj);
//get Script set from page
IHTMLDocument2 pDoc2 = (IHTMLDocument2)pObj;
IHTMLWindow2 win2 = (IHTMLWindow2)pDoc2.parentWindow;
//string code="";
win2.execScript(code, "javascript");
if (returnType == null)
[ComImport, Guid("00000118-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleClientSite
{
void SaveObject();
void GetMoniker(uint dwAssign, uint dwWhichMoniker, object ppmk);
void GetContainer(out IOleContainer ppContainer);
void ShowObject();
void OnShowWindow(bool fShow);
void RequestNewObjectLayout();
}
[ComImport, Guid("0000011B-0000-0000-C000-000000000046"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleContainer
{
void EnumObjects([In, MarshalAs(UnmanagedType.U4)] int grfFlags,
[Out, MarshalAs(UnmanagedType.LPArray)] object[] ppenum);
void ParseDisplayName([In, MarshalAs(UnmanagedType.Interface)] object pbc,
[In, MarshalAs(UnmanagedType.BStr)] string pszDisplayName,
[Out, MarshalAs(UnmanagedType.LPArray)] int[] pchEaten,
[Out, MarshalAs(UnmanagedType.LPArray)] object[] ppmkOut);
void LockContainer([In, MarshalAs(UnmanagedType.I4)] int fLock);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.