How to call JavaScript file in IEModule or IEToolbar

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

How to call JavaScript file in IEModule or IEToolbar
Need help to call JavaScript file in IEModule or IEToolbar 
Bijay Kumar Sahoo


The Biggest Risk in Life is not 2 take a Risk.


Posts: 11
Joined: 2010-04-30
Hi Team,

We have taken the license to develop Add in for Internet explorer. I am facing a problem while developing the same. I need to call some javascript funtion, But anywhere I did not find a way to call the javascript function. I only get the below one

this.HTMLDocument.parentWindow.execScript("alert(\"Wel Come To the JavaScript World !!!\")", language: "JScript");

But this is not fesiable since I have a lots pf Javascript function and also internally they are calling the other javascript methods also. Please tell me a way to call the javascript methods as well as where should i write the javascript methods for the same.

And also plz provide some contact information for live support.

Plz do for me urgently...
Thanks
Bijay Kumar Sahoo
http://www.fewlines4biju.com
Posted 19 Oct, 2010 03:00:48 Top
Digvijay Chauhan




Posts: 8
Joined: 2010-08-09
Hi Bijay,

You can inject javascript in the document when the document has finished loading in the document complete handler and then call any method from the injected script afterwards.

Look at createElement method that will allow you to add a div or something with the
<sc ript type=javascript>
your long script here
</script>

as the content of the div.

Hope that helps.

/Digvijay
Posted 19 Oct, 2010 03:14:38 Top
Bijay Kumar Sahoo


The Biggest Risk in Life is not 2 take a Risk.


Posts: 11
Joined: 2010-04-30
Can u plz give me tell where exactly get the createElement method. Please note that it is a
IEModule.cs file or IEToolbar.cs file not any aspx file.

I am really very much confused where i will put the Script tag


I have selected a project type of ADXIE toolbar from the Addin Express type of project type.
Thanks
Bijay Kumar Sahoo
http://www.fewlines4biju.com
Posted 19 Oct, 2010 03:36:24 Top
Digvijay Chauhan




Posts: 8
Joined: 2010-08-09
Hi Bijay,

You can find this method on HtmlDocument (IEApp.Document property). You should have basic knowledge of HTML Dom to traverse and manipulate it. You can even insert jQuery and use jQuery functions then.

Hope that helps.

/Digvijay
Posted 19 Oct, 2010 04:16:41 Top
Bijay Kumar Sahoo


The Biggest Risk in Life is not 2 take a Risk.


Posts: 11
Joined: 2010-04-30
Hi Digvijay
Thanks a lot for your response.

Can you please give me any url to follow.

I am really not getting to where to write the Javascript functions in the IEToolbar.cs file


Please help :cry:
Thanks
Bijay Kumar Sahoo
http://www.fewlines4biju.com
Posted 19 Oct, 2010 04:28:31 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Bijay,

Please have a look at the How to run and replace a script (JavaScript, JScript or VBScript) on an HTML page in IE 6 or 7 sample add-on project and MSDN.
.NET, Extended MAPI, Windows Phone & RT
Posted 19 Oct, 2010 04:42:08 Top
Bijay Kumar Sahoo


The Biggest Risk in Life is not 2 take a Risk.


Posts: 11
Joined: 2010-04-30
My dear friends I am just asking where should i write the Javascript function in the project. I have downloed the project and found the below line as

private void button1_Click(object sender, EventArgs e)
{
mshtml.IHTMLWindow2 window = HTMLDocument.parentWindow;
if (window != null)
{
window.execScript("done()", "JScript");
Marshal.ReleaseComObject(window);
}
}

But I did not get the declaration for the done() method througt out the project.

Please let me know where to write the javascript function ?
Thanks
Bijay Kumar Sahoo
http://www.fewlines4biju.com
Posted 19 Oct, 2010 05:14:00 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Bijay,

The "done()" method should be defined on the web page.
.NET, Extended MAPI, Windows Phone & RT
Posted 19 Oct, 2010 06:23:34 Top
Bijay Kumar Sahoo


The Biggest Risk in Life is not 2 take a Risk.


Posts: 11
Joined: 2010-04-30
Exactly the same thing i want to know. Since this is a .CS file and there is no web page in this project. So where i will put.???
Thanks
Bijay Kumar Sahoo
http://www.fewlines4biju.com
Posted 19 Oct, 2010 07:07:29 Top
Bijay Kumar Sahoo


The Biggest Risk in Life is not 2 take a Risk.


Posts: 11
Joined: 2010-04-30
Hi Finally I got something which I actually was in need. You may visit the below link to get the answer. May be it will worthful to you. But I get what I exactly wanted.

http://www.fewlines4biju.com/TopicDetails/how-to-register-js-file-into-page-in-cs-file-in-C-Sharp-net-111.aspx
Thanks
Bijay Kumar Sahoo
http://www.fewlines4biju.com
Posted 19 Oct, 2010 23:32:49 Top