一丝javascript方法
///
<summary>
///
一些常用的Javascript方法
///
</summary>
public
static
class
Jscript
{
///
<summary>
///
弹出提示框
///
</summary>
public
static
void
Alert(Page page,
string
msg)
{
string
js
=
@"
alert('
"
+
msg
+
"
')
"
;
if
(
!
page.ClientScript.IsStartupScriptRegistered(page.GetType(),
"
Alert
"
))
page.ClientScript.RegisterStartupScript(page.GetType(),
"
Alert
"
, js,
true
);
}
///
<summary>
///
弹出提示框并跳转到指定页面
///
</summary>
public
static
void
AlertAndRedirect(Page page,
string
msg,
string
ToURL)
{
string
js
=
@"
alert('{0}');window.location.replace('{1}');
"
;
js
=
string
.Format(js, msg, ToURL);
if
(
!
page.ClientScript.IsStartupScriptRegistered(page.GetType(),
"
AlertAndRedirect
"
))
page.ClientScript.RegisterStartupScript(page.GetType(),
"
AlertAndRedirect
"
,js,
true
);
}
///
<summary>
///
返回历史
///
</summary>
public
static
void
GoHistory(Page page,
int
value)
{
string
js
=
@"
history.go('{0}')
"
;
if
(
!
page.ClientScript.IsStartupScriptRegistered(page.GetType(),
"
GoHistory
"
))
page.ClientScript.RegisterStartupScript(page.GetType(),
"
GoHistory
"
,
string
.Format(js, value),
true
);
}
///
<summary>
///
关闭并使父窗口根据URL刷新
///
</summary>
public
static
void
Ref
相关文档:
原帖地址:http://www.followman.com/bbs/Topic-B11-T262.aspx
JavaScript动态响应ATL事件
相关讨论:http://topic.csdn.net/t/20061012/21/5078729.html
重
点:脚本传过来的对象是IDispatch接口,应该用IDispatch::Invoke来调用。如果传过来的是个function,那么DISPID
为0,如果是个对象,那么要先用GetIDsOfNames得 ......
当需要在网页中显示时间时可以用到下面这段代码:
<SCRIPT language=JavaScript type=text/JavaScript>
var day="";
var month="";
var ampm="";
var ampmhour="";
var myweekday="";
var year="";
mydate=new Date();
myweekday=mydate.getDay();
mymonth=mydate.getMonth()+1;
myday= mydate.getDate(); ......
基本上全部加了注释,一行一注....呵呵
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>数组排序</title>
<mce:style type="text/css"&g ......
/**
* 表格排序(单个表格,降序)
* @example
* <code>
* <table is_sort="1">
* <tr>
* <th><a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="table_sort(0, 0)">field1</a></th>
* <th><a href="javascript:void(0)" mce_href ......
方案一:
// html & JavaScript
...
<button value="Click me"
onclick="window.navigate('app:command&arg1=1&arg2=2')" />
...
// C++: 响应 的消息函数OnBeforeNavigat2
virtual void OnBeforeNavigate2( LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTar ......