相当于AppendChild/CreateElement/DomElement的axWebBrowser(FrameWork 1.1) [英] axWebBrowser (FrameWork 1.1) equivalent to AppendChild/CreateElement/DomElement

查看:100
本文介绍了相当于AppendChild/CreateElement/DomElement的axWebBrowser(FrameWork 1.1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从Framework1.1的axWebBrowser主题中的"*.js"类型的文件中注入javascript代码.

使用Framework 4.0会做得很好,但是在Framework 1.1中则不能.

这是Framework 4.0& amp;中的源代码.我想转换为Framework 1.1&的webBrowser(C#VS.2010) axWebBrowser(C#VS.2003):

HtmlElement scriptJS = webBrowser1.Document.CreateElement("script");
MSHTML.IHTMLScriptElement elementJS =(MSHTML.IHTMLScriptElement)scriptJS.DomElement;
elementJS.type ="text/javascript";
StreamReader streamReader =新的StreamReader("TheFile.js");
elementJS.text = streamReader.ReadToEnd();
streamReader.Close();
webBrowser1.Document.Body.AppendChild(scriptJS);

代码如下:
*创建一个元素< SCRIPT>并定义他的类型.
*获取源代码并将其保存到< SCRIPT>元素中.
*包括元素< SCRIPT>在文档中.

你能帮我吗?

谢谢!!!! :rolleyes:

I need to inject the javascript code from a file of type "*. js" in the subject of axWebBrowser for Framework 1.1.

With Framework 4.0 it will do very well, but in Framework 1.1 is not how.

This is the source code in Framework 4.0 & webBrowser (C# VS.2010) that I want convert to Framework 1.1 & axWebBrowser (C# VS.2003):

HtmlElement scriptJS = webBrowser1.Document.CreateElement("script");
MSHTML.IHTMLScriptElement elementJS = (MSHTML.IHTMLScriptElement)scriptJS.DomElement;
elementJS.type = "text/javascript";
StreamReader streamReader = new StreamReader("TheFile.js");
elementJS.text = streamReader.ReadToEnd();
streamReader.Close();
webBrowser1.Document.Body.AppendChild(scriptJS);

The code make this:
* Create one element <SCRIPT> and define his type.
* Get the source code and save into the element <SCRIPT>.
* Include de element <SCRIPT> in the document.

Can you help me???

Thanks!!!! :rolleyes:

推荐答案


这是在VS2005中开发的示例代码.

这里的javascript函数"initFCKEditor"驻留在fckParserEditor.jsp文件中,我们通过以下代码对其进行调用.

字符串UrlString ="http://服务器名称:端口/jsp/fckParserEditor.jsp";
webBrowser1.Url =新的Uri(UrlString);
如果(webBrowser1.Document!= null)
{
webBrowser1.Document.InvokeScript("initFCKEditor",new object [] {value});
}

希望这会有所帮助

问候
库马兰
Hi
Here is the sample code developed in VS2005.

Here the javascript function "initFCKEditor" is resides in fckParserEditor.jsp file which we are invoking it through the following code.

string UrlString = "http://servername:port/jsp/fckParserEditor.jsp";
webBrowser1.Url = new Uri(UrlString);
if (webBrowser1.Document != null)
{
webBrowser1.Document.InvokeScript("initFCKEditor", new object[] {value });
}

Hope this helps

regards
Kumaran


这篇关于相当于AppendChild/CreateElement/DomElement的axWebBrowser(FrameWork 1.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆