一丝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
相关文档:
以下事例为结合本人电脑而设计的参数,您也可改为自己的尺寸
<SCRIPT LANGUAGE="JavaScript">
var chicun;
chicun=screen.width;
if(chicun==1280||chicun==1440||chicun==1600)
{
<!--
function initEcAd() {
document.all.AdLayer1.style.posTop = -100;
document.all.AdLayer1.style.visibility = 'vis ......
1.call方法
官方(JavaScript手册):
调用一个对象的一个方法,以另一个对象替换当前对象。
call([thisObj[,arg1[,
arg2[, [,.argN]]]]])
参数
thisObj 可选项。将被用作当前对象的对象。
arg1, arg2, , argN
可选项。将被传递方法参数序列。
说明
call 方法可以用来代 ......
禁止页面刷新的javascript代码
当用户向数据库提交数据后,往往由于点击了F5刷新页面,造成数据的重复提交,很容易造成数据库数据混乱.
如果屏蔽了刷新按钮,二次提交的可能性会小很多!
下面是禁止页面刷新的javascript代码:
document.onkeydown = function()
{
if(ev ......
/**
* 表格排序(单个表格,降序)
* @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 ......