C#´úÂëÓëjavaScriptº¯ÊýµÄÏ໥µ÷ÓÃ
C#´úÂëÓëjavaScriptº¯ÊýµÄÏ໥µ÷ÓÃ
ÎÊ£º
1.ÈçºÎÔÚJavaScript·ÃÎÊC#º¯Êý?
2.ÈçºÎÔÚJavaScript·ÃÎÊC#±äÁ¿?
3.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptµÄÒÑÓбäÁ¿?
4.ÈçºÎÔÚC#ÖзÃÎÊJavaScriptº¯Êý?
ÎÊÌâ1´ð°¸ÈçÏ£º
javaScriptº¯ÊýÖÐÖ´ÐÐC#´úÂëÖеĺ¯Êý£º
·½·¨Ò»£º1¡¢Ê×ÏȽ¨Á¢Ò»¸ö°´Å¥£¬ÔÚºǫ́½«µ÷Óûò´¦ÀíµÄÄÚÈÝдÈëbutton_clickÖÐ;
2¡¢ÔÚǰ̨дһ¸öjsº¯Êý£¬ÄÚÈÝΪdocument.getElementById("btn1").click();
3¡¢ÔÚǰ̨»òºǫ́µ÷ÓÃjsº¯Êý£¬¼¤·¢clickʼþ£¬µÈÓÚ·ÃÎʺǫ́c#º¯Êý£»
·½·¨¶þ£º1¡¢º¯ÊýÉùÃ÷Ϊpublic
ºǫ́´úÂë(°Ñpublic¸Ä³ÉprotectedÒ²¿ÉÒÔ)
public string ss()
{
return("a");
}
2¡¢ÔÚhtmlÀïÓã¼%=fucntion()%£¾¿ÉÒÔµ÷ÓÃ
ǰ̨½Å±¾
£¼script language=javascript£¾
var a = "£¼%=ss()%£¾";
alert(a);
£¼/script£¾
·½·¨Èý£º1¡¢£¼script language="javascript"£¾
£¼!--
function __doPostBack(eventTarget, eventArgument)
{
var theForm = document.Form1; //Ö¸runat=serverµÄform
theForm.__EVENTTARGET.value = eventTarget;
thefrom.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
--£¾
£¼/script£¾
£¼input id="Button1" type="button" name="Button1" value="°´Å¥" onclick="javascript:__doPostBack('Button1','')"£¾
·½·¨ËÄ£º£¼script language="javascript"£¾
function SubmitKeyClick()
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = false;
document.all.FunName.value="ÄãÒªµ÷Óõĺ¯ÊýÃû"£»
document.form[0].submit();
}
}
£¼/script£¾
£¼INPUT onkeypress="SubmitKeyClick()" id="aaa" type="text"£¾
£¼input type="hidden" name="FunName"£¾ ¡´£¡--ÓÃÀ´´æ´¢ÄãÒªµ÷Óõĺ¯Êý --¡µ
ÔÚ.CSÀïÓУº
public Page_OnLoad()
{
if (!Page.IsPost())
{
string strFunName=Request.Form["FunName"]!=null?Request.Form["FunName"]:"";
//¸ù¾Ý´«»ØÀ´µÄÖµ¾ö¶¨µ÷ÓÃÄĸöº¯Êý
switch(strFunName)
{
case "enter()":
enter() ; //µ÷Óøú¯Êý
break;
case "ÆäËû":
//µ÷ÓÃÆäËûº¯Êý
break;
default:
//µ÷ÓÃĬÈϺ¯Êý
break;
}
}
}
public void enter()
{
//……±ÈÈç¼ÆËãijֵ
}
ÎÊÌâ2.ÈçºÎÔÚJavaScript·ÃÎÊC#±äÁ¿?
´ð°¸ÈçÏ£º
·½·¨Ò»£º1¡¢Í¨¹ýÒ³ÃæÉÏÒþ²ØÓò·ÃÎÊ£¼input id="xx" type="hidden" runat="server"£¾
·½·¨¶þ£º1¡¢Èçº
Ïà¹ØÎĵµ£º
scrollHeight: »ñÈ¡¶ÔÏóµÄ¹ö¶¯¸ß¶È¡£
scrollLeft:ÉèÖûò»ñȡλÓÚ¶ÔÏó×ó±ß½çºÍ´°¿ÚÖÐÄ¿Ç°¿É¼ûÄÚÈݵÄ×î×ó¶ËÖ®¼äµÄ¾àÀë
scrollTop:ÉèÖûò»ñȡλÓÚ¶ÔÏó×¶ËºÍ´°¿ÚÖпɼûÄÚÈݵÄ×¶ËÖ®¼äµÄ¾àÀë
scrollWidth:»ñÈ¡¶ÔÏóµÄ¹ö¶¯¿í¶È
offsetHeight:»ñÈ¡¶ÔÏóÏà¶ÔÓÚ°æÃæ»òÓɸ¸×ø±ê offsetParent ÊôÐÔÖ¸¶¨µÄ¸¸×ø±êµÄ¸ß¶È
offsetL ......
string cbSelectOnClickJS = @"
if(this.checked)
{
  ......
/*
ÓÉÓÚjavascriptÊÇÒ»ÖÖÎÞÀàÐÍÓïÑÔ,ËùÒÔÒ»¸öÊý×éµÄÔªËØ¿ÉÒÔ¾ßÓÐÈÎÒâµÄÊý¾ÝÀàÐÍ,ͬһ¸öÊý×éµÄ²»Í¬ÔªËØ
¿ÉÒÔ¾ßÓв»Í¬µÄÀàÐÍ,Êý×éµÄÔªËØÉèÖÿÉÒÔ°üº¬ÆäËûÊý×é,ÕâÑù¾Í¿ÉÒÔ´´½¨Ò»¸ö¸´ÔÓµÄÊý×éÁË.
²¢ÇÒÔÚÕâµãÉÏ˵javascript×÷ΪһÖֽű¾ÓïÑÔ²»Í¬ÓÚÄÇÖÖÑϸñµÄÃæÏò¶ÔÏóµÄc++.c#,javaÁË.¾ßÓиü¸ßµÄÁé»îÐÔ.
*/
/*
ÔÚjavascript ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="re ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="retu ......