һ˿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 ......
ÖÆ×÷Javascriptµ¯³ö´°¿Ú¼¼ÇɾÅÔò
1¡¢×î»ù±¾µÄµ¯³ö´°¿Ú´úÂë
¡¡¡¡Æäʵ´úÂë·Ç³£¼òµ¥£º
¡¡¡¡< SCRIPT LANGUAGE="javascript">
¡¡¡¡< !--
¡¡¡¡window.open ("page.html")
¡¡¡¡--
>
¡¡¡¡< /SCRIPT>
¡¡¡¡ÒòΪÕâÊÇÒ»¶ÎJavascript´úÂ룬ËùÒÔËüÃÇÓ¦¸Ã·ÅÔÚ< SCRIPT LANGUAGE="javascript">Ö®¼ä¡£ ......
ÎÒÃǾ³£ÐèÒªÔÚJavaScriptÖиøElement¶¯Ì¬Ìí¼Ó¸÷ÖÖÊôÐÔ£¬Õâ¿ÉÒÔͨ¹ýʹÓÃsetAttribute()À´ÊµÏÖ£¬Õâ¾ÍÉæ¼°µ½ÁËä¯ÀÀÆ÷µÄ¼æÈÝÐÔÎÊÌâ¡£
setAttribute(string name, string value)£ºÔö¼ÓÒ»¸öÖ¸¶¨Ãû³ÆºÍÖµµÄÐÂÊôÐÔ£¬»òÕß°ÑÒ»¸öÏÖÓеÄÊôÐÔÉ趨Ϊָ¶¨µÄÖµ¡£
1¡¢ÑùʽÎÊÌâ
setAttribute(class, value)ÖÐclassÊÇÖ¸¸Ä±äclassÕâ¸öÊôÐ ......
JavaScript ʱ¼ä¼Ó¼õ:
<HTML>
<BODY>
<script type="text/javascript">
var time = new Date("04/30/2010");
document.write(time);
......
Ò»¸öÍêÕûµÄʼþϵͳ£¬Í¨³£´æÔÚÒÔÏÂÈý¸ö½ÇÉ«£º
ʼþ¶ÔÏó£¬ÓÃÓÚ´¢´æÊ¼þµÄ״̬¡£
ʼþÔ´¶ÔÏ󣬵±Ç°Ê¼þÔÚ²Ù×÷µÄ¶ÔÏó£¬ÈçÔªËØ½Úµã£¬Îĵµ¶ÔÏó£¬window¶ÔÏó£¬XMLHttpRequest¶ÔÏóµÈ¡£
ʼþ¼àÌýÆ÷£¬µ±Ò»¸öʼþÔ´Éú³ÉÒ»¸öʼþ¶ÔÏóʱ£¬Ëü»áµ÷ÓÃÏàÓ¦µÄ»Øµ÷º¯Êý½øÐвÙ×÷¡£ÔÚIEÖУ¬Ê¼þ¶ÔÏóºãΪȫ¾ÖÊôÐÔwindow.eventµÄ·ÖÉí¡£
ÔÚw3cà ......