通过WebBrowser修改JavaScript函数
网页代码
HTML code:
<html>
<head>
<script>
var hello="修改前";
function showmsg(){
alert("修改前");
};
</script>
</head>
<body onload=showmsg()>
修改
</body>
</html>
C/C++ code:
//对于变量可以更改
//获取hello变量
void __fastcall TMainForm::Button6Click(TObject *Sender)
{
AnsiString s;
Variant v;
v=Web->Document;
v=v.OlePropertyGet("Script");
s=v.OlePropertyGet("hello");
ShowMessage(s);
}
//设置hello变量
void __fastcall TMainForm::Button8Click(TObject *Sender)
{
Variant v,vs;
v=Web->Document;
v=v.OlePropertyGet("Script");
v.OlePropertySet("hello","修改后");
}
问题:
如果我想改变showmsg函数,比如把showmsg函数体改为:
function showmsg(){
var i=0;
};
应怎么改呢?
给你一篇C#的
http://blog.csdn.net/songkexin/archive/2009/12/25/5072898.aspx
自己已解决.
相关问答:
怎么用javascript控制gridview里的RadioButton
对 gridview findcontrol ,找出RadioButton,
然后,对RadioButton ,的Attribute 增加 JS就可以了。
C# code:
for (int i = 0; i < gd ......
用javascript加载页面时指向一个描点。已知如何通过链接做成描点的,可是想让页面加载时直接指向不需要点击链接。
1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ......
<script language="javascript">
function click() {
if (event.button==2) { //button==1为左键
alert('点击查看文章详细内容!')
}
}
document.onmousedown=click
</script>
以上 ......
我的源文件如下:
<html>
<head> <title>show picture </title>
<script>
function change(fileName)
{
  ......
各位使用js的高手. 小弟问几个问题,请大家帮忙解答.困扰了我2个星期了.一直不太明白.
比如 :
Div1 是一个层;
var myitem=new Item(document.getElem ......