һ˿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
Ïà¹ØÎĵµ£º
ä¯ÀÀÆ÷ÒѾ¿´µ½µÄ¶«Î÷¶¼´æÔÚ»º´æÎļþ¼ÐÀï¡£
½Å±¾×¢ÊÍ: µ¥ÐÐ// ¶àÐÐ/*....*/
Æô¶¯Ê±ºò¼ÓÔØfunction() window.onload= function;
alert Ìáʾ¶Ô»°¿ò alert("ÌáʾÄÚÈÝ");
promptÌáʾÊäÈë¿òprompt("ÌáʾÄÚÈÝ","ĬÈÏÖµ")£»
JavaScriptÖØ¶¨Ïò ÔÚ×°ÔØÒ³ÃæÊ±£¬²»ÄÜÔÚ×°ÔØÍêÖ ......
ÎÒÃǾ³£ÐèÒªÔÚJavaScriptÖиøElement¶¯Ì¬Ìí¼Ó¸÷ÖÖÊôÐÔ£¬Õâ¿ÉÒÔͨ¹ýʹÓÃsetAttribute()À´ÊµÏÖ£¬Õâ¾ÍÉæ¼°µ½ÁËä¯ÀÀÆ÷µÄ¼æÈÝÐÔÎÊÌâ¡£
setAttribute(string name, string value)£ºÔö¼ÓÒ»¸öÖ¸¶¨Ãû³ÆºÍÖµµÄÐÂÊôÐÔ£¬»òÕß°ÑÒ»¸öÏÖÓеÄÊôÐÔÉ趨Ϊָ¶¨µÄÖµ¡£
1¡¢ÑùʽÎÊÌâ
setAttribute(class, value)ÖÐclassÊÇÖ¸¸Ä±äclassÕâ¸öÊôÐ ......
ºÜ¶àÈ˶¼ÏòÔÚ·þÎñÆ÷
¶Ëµ÷Óÿͻ§¶ËµÄº¯ÊýÀ´²Ù×÷£¬Ò²¾ÍÊÇÔÚaspÖе÷ÓÃjava
script½Å±¾ÖÐÒѾ¶¨ÒåºÃµÄ½Å±¾º¯Êý¡£¾¹ýÑо¿£¬·¢ÏÖÁËһЩÃãÇ¿µÄ·½·¨¡£
1.
ÓÃResponse.Write·½·¨Ð´Èë½Å±¾
±ÈÈçÔÚÄãµ¥»÷°´Å¥ºó£¬ÏȲÙ×÷Êý¾Ý¿â
£¬ÍêÁ˺óÏÔʾÒѾÍê³É£¬¿ÉÒÔÔÚ×îºóÏëµ÷Óõĵط½Ð´ÉÏ
Response.Write("<script type='text/j ......
×î½üÒªÓõ½Ïà¹Ø¼¼Êõ£¬ÏÈÌùÔÚÕ⣬ÓпÕÔÙ·Ò³¡£
±¾ÎÄת×Ô£º
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 usi ......
½ûÖ¹Ò³ÃæË¢ÐµÄjavascript´úÂë
µ±Óû§ÏòÊý¾Ý¿âÌá½»Êý¾Ýºó,ÍùÍùÓÉÓÚµã»÷ÁËF5Ë¢ÐÂÒ³Ãæ,Ôì³ÉÊý¾ÝµÄÖØ¸´Ìá½»,ºÜÈÝÒ×Ôì³ÉÊý¾Ý¿âÊý¾Ý»ìÂÒ.
Èç¹ûÆÁ±ÎÁËˢа´Å¥,¶þ´ÎÌá½»µÄ¿ÉÄÜÐÔ»áСºÜ¶à!
ÏÂÃæÊǽûÖ¹Ò³ÃæË¢ÐµÄjavascript´úÂë:
document.onkeydown = function()
{
if(ev ......