How to use Javascript using Addins

Add-in Express™ Support Service
That's what is more important than anything else

How to use Javascript using Addins
 
Sergey Grischenko


Add-in Express team


Posts: 7228
Joined: 2004-07-05
There is no code for this subject. All is done at the design time. You just need to add a new context menu item using the 'Edit Context Menu Items' option of the iemodule.
Posted 08 Sep, 2011 12:37:35 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
Where can i add the Context Menu item?? I am using a plugins i,e adding a toolbar. and in that toolbar put 1 button.So in design time which control i need to add?Tell me the process at least how to do in design time.Now i am in MyIEToolbar1.cs(design).Only this page is there(design).Here how can i add that menu??

Thanks
Posted 08 Sep, 2011 12:51:13 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
Actually Sergey we can get the id/name of html if its a simple input html tag,for example i am getting the Subject id/Name and the value also coming.But in case of To,CC,Bcc its something different.They are not using simple control.Can you please open one hotmail and yahoomail and see how the 'To' is coming??

Thanks
Rajesh
Posted 08 Sep, 2011 13:12:09 Top
Sergey Grischenko


Add-in Express team


Posts: 7228
Joined: 2004-07-05
Hi Rajesh.

Add-in Express IE toolbar has the IEContextMenu collection. It is also available via the 'Edit Context Menu Items' option of the toolbar module.
Posted 09 Sep, 2011 05:43:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7228
Joined: 2004-07-05
Rajesh, did you try to use the code below on hotmail and yahoomail (of course, you need to add the correct tag name in GetHTMLElementsByTagName method)?

object[] frames = AddinExpress.IE.ADXIEHelper.GetFrames(this.HTMLDocumentObj);
foreach (mshtml.IHTMLWindow2 elem in frames)
{
mshtml.IHTMLDocument2 doc =
AddinExpress.IE.ADXIEHelper.GetFrameDocument(elem) as mshtml.IHTMLDocument2;

object[] all = AddinExpress.IE.ADXIEHelper.GetHTMLElementsByTagName(doc, "body");
foreach (mshtml.HTMLBodyClass body in all)
{
if (body.className != null && body.className == "editable LW-yrriRe")
MessageBox.Show(this, body.innerText);
}
}
Posted 09 Sep, 2011 05:45:54 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi,
The above code is possible for Gmail only.Because they are using only single control for To,cc,Bcc etc..But the same thing is not applying to Hotmail or yahoo mail.They are using some ul and these are generating dynamically.But the Constant 'div' is there.So can you please help me is there any way to find the all value from the 'div'??

And here anyhow we cannot use javascript.So please help me how to get the all value in that 'div' tag?? or How can we get the HTMLElements By 'Id'?? Please send me some code..

Thanks in advance..



Thanks
Raju
Posted 09 Sep, 2011 07:59:31 Top
Sergey Grischenko


Add-in Express team


Posts: 7228
Joined: 2004-07-05
To get HTML elements by ID you can use GetHTMLElementByID method of the AddinExpress.IE.ADXIEHelper class. Also, you can use the getElementById method of the HTML document object. http://msdn.microsoft.com/en-us/library/ms536437(v=vs.85).aspx
I don't know all possible child elements of the 'div' tag because they depend on the source code of the web page. You can use the Developer Tools dialog of IE (just press F12) to explore the source code of the active webpage.
Posted 09 Sep, 2011 11:16:50 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi Sergey,
Now i am facing a problem in hotmail , Using the below methos its not possible.
IHTMLElement elemt = this.HTMLDocument.getElementById("AutoCompleteTo$InputDiv");
string str=elemt.innerHTML;
But this one is not working in HOTMAIl.Please help me for one..Its very urgent...Give me some code..

And i have one more problem is that i want to use Regex In C#.How can i write the code??
Here are the example regexes that the plugin's should apply to determine which file to inject

gmail: ^https?://mail\.google\.com/

yahoo: ^https?://([^/]+\.)+mail\.yahoo\.com/

hotmail: [/\.]mail\.live\.com($|/)

Using this Regex i can determine which url is open?? So how to apply this code in my .CS file? Please give me some idea.



Thanks
Raju
Posted 10 Sep, 2011 14:43:04 Top
Sergey Grischenko


Add-in Express team


Posts: 7228
Joined: 2004-07-05
Posted 12 Sep, 2011 14:33:20 Top
raju kumar




Posts: 20
Joined: 2011-08-13
Hi Sergey,
Now i have problem only in hotmail , Using the below methos its not possible.
IHTMLElement elemt = this.HTMLDocument.getElementById("AutoCompleteTo$InputDiv");
string str=elemt.innerHTML;
But this one is not working in HOTMAIl.Please Check with the Hotmail Compose Mail source code and check with the div Id But still its not working...Please help me out..

Sergey,
Can you please tell me one thing How can we get Details from HTMLelements By using getElementsByTagName??
I am trying to write like below.
IHTMLElement objelement = this.HTMLDocument.getElementsByTagName("li").ToString();
But its give me the error as cannot implicitly convert string to MSHTML.IHTMLElement..

Please rectify the code so that i can get details from getElementByTagname??



Rajesh
Posted 13 Sep, 2011 05:35:17 Top