如何获取C#Winform程序中javascript生成的值? [英] How to get the value which generated by javascript in C# Winform program?

查看:79
本文介绍了如何获取C#Winform程序中javascript生成的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想获取由javascript生成的值,而不是在C#Winform程序中显示在Web浏览器内容中的值(而不是在html源代码中)

我在调试文件夹中有一个getXY.html.它可以显示经纬度和经度,而没有其他显示.

然后将lat和lng放入div id = position
getXY.html中的html模拟代码为:


函数displayPosition()
{
var content = document.getElementById("position");
content.innerHTML = getPosition();
}
函数getPosition()
{
.........
}


Hi all,

I want to get the valuse which generated by javascript and than displayed in the webbrowser''s content,(not in the html source) in C# Winform program

I have a getXY.html in the debug folder. It can show the lat and lng and nothing else.

And I put the lat and lng into div id=position
the html mock-up code in getXY.html is:


function displayPosition()
{
var content = document.getElementById("position");
content.innerHTML = getPosition();
}
function getPosition()
{
.........
}






因此,假设我的职位是20-45.并且它们是将在网络浏览器中显示的唯一字母.

但是我尝试了多种方法来获取显示在页面上的20-45.都失败了.
我得到的是整个HTML代码,对我来说是无用的.....

因此,我想知道您对此有什么想法吗?





So let''s say my position is, 20,-45. and they are the only letters which will be showed on the web broswer.

but I tried a lot of different ways to get the 20,-45 which displayed on the page. And all faild.
What I got it is the whole html code which is useless for me.....

So I am wondering that do you have any idea about it?

推荐答案

使您的HTML有效XML(因此,使其成为XHTML),然后使用其中一种XML解析.NET中的类进行搜索,或使用正则表达式从完整的html中提取值.
Make your HTML valid XML ( so, make it XHTML ) and then use one of the XML parsing classes in .NET to search for it, or use a regex to extract your values from the full html.


好吧,如果您的div的ID为"position"(以及您的标记在HTML中正确关闭),您应该可以使用content.InnerHtml来检索div中的所有内容.

到那时(根据您的小便描述),您只需在内部html"上调用string.Split('','')并将结果字符串部分转换为Int32,您将获得所需的结果.

当然,我只是在猜测,因为您的问题(按目前的措词)很糟糕,并且您的问题标签可能不完整.
Well, if your div''s ID is "position" (and your tags are properly closed in the HTML), you should be able to use content.InnerHtml to retrieve everything inside the div.

At that point (according to your piss-poor description), you can simply call string.Split('','') on the "inner html" and convert the resulting string parts to Int32, and you''ll get the results you''re after.

Of course, I''m only guessing because your question (as it''s currently worded) sucks and your question tags are probably incomplete.


我通过延迟检索过程来解决了该问题数据来自html代码,因此过一会儿,经纬度将被更新为html代码,然后使用Christian Graus答案中所述的方法.谢谢男人:)
I solved it by delaying the process of retrieving data from html code, so after a while, the lat and lon will be updated into the html code and then using the method stated in the Christian Graus answer. thanks man :)


这篇关于如何获取C#Winform程序中javascript生成的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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