积极答复者
C#如何获取到javascript链接的网址

问题
-
小弟我想搞个自动建单的系统,,用的C#winform 控件用的是webBroswer。
现在遇到的情况是登陆到网址(已解决),然后点击下面那个a,然后弹出表单框填写。
<a id="idFileNewCR" class="menu" href="JavaScript: ahdtop.create_new('cr',0,'','','PRESET=type:R','PRESET=z_cur_task:101000','PRESET=z_cur_task_status:1');"> 新建单</a>
之前我找一个这样的href 我用ID属性无法点击,我就直接用下面那条语句打开。
webBrowser.Navigate("javascript:window.parent.content.setActKeyMenuState(0)")
打开后,是弹出一个IE框来输入表单信息的,我在网上找了下,不要弹出框的都无法实现。
有什么方法可以截取到这个javascript反馈回来的链接。。
答案
-
你要获取href属性包含的内容,可以在webBrowser的DocumentCompleted事件中:
webBrowser1.Document.GetElementById("idFileNewCR").GetAttribute("href");
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats- 已标记为答案 笨山猴 2013年3月8日 6:00
-
你这个标签是不是放在一个Frame里边?可以给出全部完整的Html吗?
或者把你Html代码静态页和你的程序上传到SkyDrive,我们看看呢?
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats- 已标记为答案 笨山猴 2013年3月8日 6:00
-
你截包看ie打开表单的URL,直接navigate
- 已建议为答案 Jason Dot WangModerator 2013年3月6日 4:40
- 已标记为答案 笨山猴 2013年3月8日 6:00
全部回复
-
你要获取href属性包含的内容,可以在webBrowser的DocumentCompleted事件中:
webBrowser1.Document.GetElementById("idFileNewCR").GetAttribute("href");
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats- 已标记为答案 笨山猴 2013年3月8日 6:00
-
你要获取href属性包含的内容,可以在webBrowser的DocumentCompleted事件中:
webBrowser1.Document.GetElementById("idFileNewCR").GetAttribute("href");
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
我尝试了下,不行啊,会出现这个“未将对象引用设置到对象的实例。”错误,是null、、、、、 -
你这个标签是不是放在一个Frame里边?可以给出全部完整的Html吗?
或者把你Html代码静态页和你的程序上传到SkyDrive,我们看看呢?
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats- 已标记为答案 笨山猴 2013年3月8日 6:00
-
你截包看ie打开表单的URL,直接navigate
- 已建议为答案 Jason Dot WangModerator 2013年3月6日 4:40
- 已标记为答案 笨山猴 2013年3月8日 6:00