JavaScript Calls from C++
最近要用到相关技术,先贴在这,有空再翻页。
本文转自:
http://www.codeguru.com/Cpp/I-N/ieprogram/article.php/c4399
http://www.codeguru.com/cpp/i-n/ieprogram/article.php/c4399/JavaScript-Calls-from-C.htm
http://www.codeproject.com/KB/COM/jscalls.aspx
Introduction
Sometimes, when we are using the IE Browser Control inside of a C++ application, we need to access the HTML elements. We can do it by using standard COM objects such as IWebBrowser2 , IHTMLDocument2 , and so forth. By doing this, we easily can implement features such as click button, click anchor, get input string, get HTML text, and so on. Unfortunately, Microsoft did not provide similar objects for JavaScript. In any case, it is possible to make a control for the JavaScript object inside an HTML page by using a traditional COM approach. This article describes the class CWebPage that allows you to do it and a technique to call a JavaScript function from C++ code.
How to Do This
As the result of using the presented class, it will be easy to call any JavaScript function from C++ code. To implement this feature, we should get a pointer to the IHTMLDocument2 interface. If we are using the CHtmlView class from MFC, we can get one by using member function CHtmlView::GetHtmlDocument() . In the case of using the IWebBrowser or IWebBrowser2 components, the function get_Document will bring us the desired interface. Here is an example:
CComPtr<IDispatch> spDisp = CHtmlView::GetHtmlDocument();
m_webPage.SetDocument(spDisp);
The rest of the things will be done by the CWebPage class. Here is an example of a JavaScript call without parameters.
m_webPage.CallJScript("Welcome");
The example of the JavaScript call with two parameters will look like this:
m_webPage.CallJScript("Miltiply","2.34","3.32");
The Class Implementation
class CWebPage
{
public:
CWebPage();
virtual ~CWebPage();
bool SetDocument(IDispatch* pDisp);
LPDISPATCH GetHtmlDocument() const;
const CString GetLastErr
相关文档:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head >
<title></title>
</head>
<body>
<form id="form1">
<div>
& ......
JavaScript获取DOM节点元素
在Web应用程序特别是Web2.0程序开发中,经常要获取页面中某个元素,然后更新该元素的样式、内容等。如何获取要更新的元素,是首先要解决的问题。令人欣慰的是,使用JavaScript获取节点的方法有很多种,这里简单做一下总结:
通过顶层document节点获取:
1. document.getElement
......
JavaScript 是一款强大的广泛运用于现代Web站点及应用的脚本语言。作为一个技艺精湛的 Web 开发者,掌握JavaScript可以增强用户的使用体验,提供交互及富客户端等功能。
尽管JavaScript 的语法非常简单,但对于写程序而言仍然是困难重重,就是因为它的运行环境:基于Web浏览器。
以下您可以看到收集的8个实用的 JavaScrip ......
第3章 怎样才能高效率测试
3.1 似是而非的高效率
这一节澄清一些流行的误解或误导,一些看起来很不错的高效率,实际上是似是而非的。
全自动生成用例
全自动生成用例是所有测试人员的期盼,好消息是,这是一种简单的技术,十年前就有了,坏消息是,这种技术作用很小。
......
今天继续学习java和android平台 java的学习算是补充,因为没有java基础也做不出什么东西来
今天看到java用this关键字来重载构造方法,在这里做个笔记class a_sample{
public int x,y.z;
a_sample(int x){
this.x=x;
}
a_sample(int x,int y){
this(x);
this.y=y;
}
a_sample(int x ......