在C/S中,如何用Javascript写脚本?或者说,如何调用?

颤菊大师 2009-06-02 12:42:26
前些天,有一个招聘的人来找我,他是自己“开”私服的。其中他传了一个游戏的脚本(冒险岛)给我。我发现时Javascript的代码。
请问,.NET可以在C/S(WPF??)中调用js文件里的代码么?
如果可以,怎么调用?(js不是只可以操作DOM对象么?)
...全文
188 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
颤菊大师 2009-06-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 Jinshu2003 的回复:]
可以的.


C# code axWb = new AxSHDocVw.AxWebBrowser();
private void NoAlert()
{
string strScript = "window.alert = null;window.confirm = null;window.open = null;window.showModalDialog = null;";

//strScript = "alert('testsssssssss')";
//(axWebBrowser1.Document as IHTMLDocument2).parentWindow.execScript(strScript, "javascript");

[/Quote]

长见识了!天哦!
  • 打赏
  • 举报
回复
可以的.

 axWb = new AxSHDocVw.AxWebBrowser();  
private void NoAlert()
{
string strScript = "window.alert = null;window.confirm = null;window.open = null;window.showModalDialog = null;";

//strScript = "alert('testsssssssss')";
//(axWebBrowser1.Document as IHTMLDocument2).parentWindow.execScript(strScript, "javascript");
// strScript = "window.alert =function(){return;}";

IHTMLDocument2 dc = axWb.Document as IHTMLDocument2;
try
{
dc.parentWindow.execScript(strScript, "javascript");
}
catch
{
}
}

或者 WebWebBrowser 控件里面 直接掉那个 js脚本里面的 函数名称也可以。
WebBrowser.InvokeScript 函数。
你在网上查一下这个。 不好意思 没实际代码。
APP开发王 2009-06-02
  • 打赏
  • 举报
回复
axWb = new AxSHDocVw.AxWebBrowser();
private void NoAlert()
{
string strScript = "window.alert = null;window.confirm = null;window.open = null;window.showModalDialog = null;";

//strScript = "alert('testsssssssss')";
//(axWebBrowser1.Document as IHTMLDocument2).parentWindow.execScript(strScript, "javascript");
// strScript = "window.alert =function(){return;}";

IHTMLDocument2 dc = axWb.Document as IHTMLDocument2;
try
{
dc.parentWindow.execScript(strScript, "javascript");
}
catch
{
}
}



或者 WebWebBrowser 控件里面 直接掉那个 js脚本里面的 函数名称也可以。
WebBrowser.InvokeScript 函数。
你在网上查一下这个。 不好意思 没实际代码。


UP
APP开发王 2009-06-02
  • 打赏
  • 举报
回复
axWb = new AxSHDocVw.AxWebBrowser();
private void NoAlert()
{
string strScript = "window.alert = null;window.confirm = null;window.open = null;window.showModalDialog = null;";

//strScript = "alert('testsssssssss')";
//(axWebBrowser1.Document as IHTMLDocument2).parentWindow.execScript(strScript, "javascript");
// strScript = "window.alert =function(){return;}";

IHTMLDocument2 dc = axWb.Document as IHTMLDocument2;
try
{
dc.parentWindow.execScript(strScript, "javascript");
}
catch
{
}
}



或者 WebWebBrowser 控件里面 直接掉那个 js脚本里面的 函数名称也可以。
WebBrowser.InvokeScript 函数。
你在网上查一下这个。 不好意思 没实际代码。


UP
wujinjian2008n 2009-06-02
  • 打赏
  • 举报
回复
up
sunhuaiwei 2009-06-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 Jinshu2003 的回复:]
可以的.


C# code axWb = new AxSHDocVw.AxWebBrowser();
private void NoAlert()
{
string strScript = "window.alert = null;window.confirm = null;window.open = null;window.showModalDialog = null;";

//strScript = "alert('testsssssssss')";
//(axWebBrowser1.Document as IHTMLDocument2).parentWindow.execScript(strScript, "javascript");

[/Quote]
up
在嵌入式web服务器boa框架的基础上, 使用C语言cgi, 或者Python脚本, 结合HTML + javascript + ajax 的嵌入式web系统的开发实例 html 使用javascritp + ajax 从C语言生成的cgi文件的get, set 一些值. boa服务器的相关配置参数说明: http://www.cnblogs.com/liuweiqiang/p/3859130.html boa安装包文件名: boa-for-hi3516a.tar.gz boa.conf 文件的保存路径: cat /etc/boa/boa.conf boa可 执行文件的路径: /usr/local/bin/boa, 可以设置为: 系统启动的时候, 这个进程自动启动 boa.conf 文件的重要参数 保存html文件的目录 DocumentRoot /www 可以将这个目录, 设置为samb共享文件夹的目录, 方便修改调试 修改完成以后, 肯定要重启boa进程的 保存python脚本, 或者C语言cgi文件的目录 ScriptAlias /cgi-bin/ /var/www/cgi-bin/ 说明: cgi-bin/ 后面的斜杠, 一定要加上 可以将这个目录, 设置为samb共享文件夹的目录, 方便修改调试 修改完成以后, 肯定要重启boa进程的 html文件文件, 调用python脚本的时候, 指定的路径, 需要有: /cgi-bin, 比如: var url = "/cgi-bin/getuser.py"; 这个是python 或者 var url = "/cgi-bin/output.cgi"; 这个是C语言 说明: 如果发现, html文件, 修改了, 可是在浏览器, 查看html源代码的时候, 这个代码, 还是旧的, 那么可以通过清空"IE浏览器", "360浏览器"的浏览记录 以上, javascript 可以调用python 同样, 也可以调用C语言生成的cgi文件(其实, 就是可执行文件) C语言 + Html 例子 C语言 CGI实例 http://blog.csdn.net/ajrm0925/article/details/8810342 http://blog.csdn.net/liang890319/article/details/6277900 http://blog.csdn.net/gnefniu/article/details/42432657 上传文件: http://blog.csdn.net/yu_xiang/article/details/7996670 查找文件 find . -type f -name "boa.conf" -print -mount find . -type f -name "boa" -print -mount 四、嵌入式web服务器boa的配置和使用 嵌入式web服务器boa的配置文件为boa.conf, 在boa-0.94.13目录下面,复制该文件到文件 系统的/etc/boa目录下面,打开boa.conf,修改为如下内容: Port 80 User root Group root ErrorLog /dev/console AccessLog /dev/null ServerName SoftEmbed.com DocumentRoot /www DirectoryIndex index.html KeepAliveMax 1000 KeepAliveTimeout 10 MimeTypes /etc/mime.types DefaultType text/plain CGIPath /bin:/usr/bin:/usr/local/bin ScriptAlias /cgi-bin/ /www/cgi-bin/ 几个重要配置参数如下: DocumentRoot: 存放html文档的主目录; DirectoryIndex: 默认返回的html文档; ScriptAlias:cgi脚本虚拟路径对应的实际路径,/www/cgi-bin/为cgi脚本存放的实际路径; 其他配置选项的意义请参考相关资料。 复制boa可执行文件到/usr/sbin目录, 启动boa进程 重新制作文件系统,系统启动后,在客户端浏览器上输入开发板的ip 地址,例如: http://192.168.0.218, 就可以看到显示的测试网页了,如下图所示 CGI getenv函数的参数详解: http://www.cnblogs.com/ser0632/p/5498228.html s = getenv("环境变量名"); 取得环境变量内容 putenv改变或增加环境变量 int putenv(const char * string); setenv(改变或增加环境变量) http://www.jb51.net/article/71940.htm

111,119

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧