Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaScriptÓëC# WindowsÓ¦ÓóÌÐò½»»¥·½·¨

Ò»¡¢½¨Á¢ÍøÒ³
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<script language="javascript" type="text/javascript">
<!-- Ìṩ¸øC#³ÌÐòµ÷Óõķ½·¨ -->
function messageBox(message)
{
alert(message);
}
</script>
</head>
<body>
<!-- µ÷ÓÃC#·½·¨ -->
<button onclick="window.external.MyMessageBox('javascript·ÃÎÊC#´úÂë')" >
javascript·ÃÎÊC#´úÂë</button>
</body>
</html>
¶þ¡¢½¨Á¢WindowsÓ¦ÓóÌÐò
1. ´´½¨WindowsÓ¦ÓóÌÐòÏîÄ¿
2. ÔÚForm1´°ÌåÖÐÌí¼ÓWebBrowser¿Ø¼þ
3. ÔÚForm1ÀàµÄÉÏ·½Ìí¼Ó
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
ÕâÊÇΪÁ˽«¸ÃÀàÉèÖÃΪcom¿É·ÃÎÊ¡£Èç¹û²»½øÐиÃÉùÃ÷½«»á³ö´í¡£³ö´íÐÅÏ¢ÈçÏÂͼËùʾ£º
È磺
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public partial class Form1 : Form
4£®³õʼ»¯WebBrowserµÄUrlÓëObjectForScriptingÁ½¸öÊôÐÔ¡£
UrlÊôÐÔ£ºWebBrowser¿Ø¼þÏÔʾµÄÍøҳ·¾¶
ObjectForScriptingÊôÐÔ£º¸Ã¶ÔÏó¿ÉÓÉÏÔʾÔÚWebBrowser¿Ø¼þÖеÄÍøÒ³Ëù°üº¬µÄ½Å±¾´úÂë·ÃÎÊ¡£
½«UrlÊôÐÔÉèÖÃΪÐèÒª½øÐвÙ×÷µÄÒ³µÄURL·¾¶¡£
JavaScriptͨ¹ýwindow.externalµ÷ÓÃC#¹«¿ªµÄ·½·¨¡£¼´ÓÉObjectForScriptingÊôÐÔÉèÖõÄÀàµÄʵÀýÖÐËù°üº¬µÄ¹«¹²·½·¨¡£¾ßÌåÉèÖÃÀý×ÓÈçÏ£º
System.IO.FileInfo file = new System.IO.FileInfo("index.htm");
// WebBrowser¿Ø¼þÏÔʾµÄÍøҳ·¾¶
webBrowser1.Url = new Uri(file.FullName);
// ½«µ±Ç°ÀàÉèÖÃΪ¿ÉÓɽű¾·ÃÎÊ
webBrowser1.ObjectForScripting = this;
5£®C#µ÷ÓÃJavaScript·½·¨
ͨ¹ýWebBrowserÀàµÄDocumentÊôÐÔÖеÄInvokeScript·½·¨µ÷Óõ±Ç°ÍøÒ³µÄJavascript·½·¨¡£È磺
// µ÷ÓÃJavaScriptµÄmessageBox·½·¨£¬²¢´«Èë²ÎÊý
object[] objects = new object[1];
objects[0] = "C#·ÃÎÊJavaScript½Å±¾";
webBrowser1.Document.InvokeScript("messageBox", objects);
ÍêÕû´úÂëÈçÏ£º
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
System.IO.FileInfo file = new System.IO.FileInfo("index.htm");
// WebBrowser¿Ø¼þÏÔʾµÄÍøҳ·¾¶
webBrowser1.U


Ïà¹ØÎĵµ£º

Javascript±Õ°ü(Closure)

ClosureÖÐÎÄ·­ÒëΪ±Õ°ü.×ÖÃæÉÏÀ´Àí½â¾ÍÊÇ"·â±ÕµÄ°ü".(ÕâÊÇÒ»¾ä·Ï»°)
±Õ°üÊÇʲô?
ÊéÃæ½âÊÍΪ: Ëùν“±Õ°ü”£¬Ö¸µÄÊÇÒ»¸öÓµÓÐÐí¶à±äÁ¿ºÍ°ó¶¨ÁËÕâЩ±äÁ¿µÄ»·¾³µÄ±í´ïʽ£¨Í¨³£ÊÇÒ»¸öº¯Êý£©£¬Òò¶øÕâЩ±äÁ¿Ò²ÊǸñí´ïʽµÄÒ»²¿·Ö¡£
ÎÒÈÏΪ±Õ°ü¾ÍÊÇÄܹ»¶Á/дº¯ÊýÄÚ²¿µÄijЩ±äÁ¿µÄ×Óº¯Êý,²¢½«ÕâЩ±äÁ¿±£´æÔÚÄÚ´æÖÐ.
± ......

javaScript¹Ø±Õä¯ÀÀÆ÷ (²»µ¯³öÌáʾ¿ò)

Ò»¶ÎJavaScript½Å±¾³ÌÐò£¬¸ºÔð¹Ø±Õ´°¿Ú£¬Èç¹ûÍøÒ³²»ÊÇͨ¹ý½Å±¾³ÌÐò´ò¿ªµÄ£¨window.open()£©£¬µ÷ÓÃwindow.close()½Å±¾¹Ø±Õ´°¿ÚÇ°£¬±ØÐëÏȽ«window.opener¶ÔÏóÖÃΪnull£¬·ñÔòä¯ÀÀÆ÷£¨IE7¡¢IE8£©»áµ¯³öÒ»¸öÈ·¶¨¹Ø±ÕµÄ¶Ô»°¿ò¡£
£¼script language="javaScript"£¾
function closeWindow()
{
¡¡window.opener = null;
¡¡w ......

Javascript: setTimeout()ʹÓü° setInterval()ʹÓÃ

Evaluates an expression after a specified number of milliseconds has elapsed.
(ÔÚÖ¸¶¨Ê±¼ä¹ýºóÖ´ÐÐÖ¸¶¨µÄ±í´ïʽ)
Syntax:
iTimerID = window.setTimeout(vCode, iMilliSeconds [, sLanguage])
Parameters
vCode
Required. Variant that specifies the function pointer or string that indicates the code to be ......

ÏñASPÒ»ÑùÇáËÉʵÏÖ·ÖÒ³ÏÔʾÊý¾ÝC#

 
´úÂëÈçÏ£º
<%@ Page Language="C#" Debug="true" %>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
<Script Language="C#" runat="server">
int Record_Per_Page;//¶¨ÒåÿҳÏÔʾ¼Ç¼Êý
int nPageCount;//¶¨Òå×ÜÒ³Êý
int nRecCount;//¶¨Òå×Ü ......

javascript ½ûÖ¹Êó±êÓÒ¼ü...

<body oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onbeforecopy="return false" onmouseup=document.selection.empty() oncopy=document.selection.empty() onselect=document.selection.empty()></body>
½²ÉÏÃæºìÉ«ÏÔʾµÄ²åÈëµ½ÍøÒ³ÖоͿÉÒÔʵÏÖÊó±êÓÒ»÷ÎÞЧ
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ