Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Îļþ²Ù×÷

Ò»¡¢¹¦ÄÜʵÏÖºËÐÄ£ºFileSystemObject ¶ÔÏó
    ÒªÔÚjavascriptÖÐʵÏÖÎļþ²Ù×÷¹¦ÄÜ£¬Ö÷Òª¾ÍÊÇÒÀ¿¿FileSystemobject¶ÔÏó¡£
¶þ¡¢FileSystemObject±à³Ì
ʹÓÃFileSystemObject ¶ÔÏó½øÐбà³ÌºÜ¼òµ¥£¬Ò»°ãÒª¾­¹ýÈçϵIJ½Ö裺 ´´½¨FileSystemObject¶ÔÏó¡¢Ó¦ÓÃÏà¹Ø·½·¨¡¢·ÃÎʶÔÏóÏà¹ØÊôÐÔ ¡£
£¨Ò»£©´´½¨FileSy ......

Ïñ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£ºDOM²Ù×÷ÓÅ»¯

Ô­ÎÄ£º¡¶Speeding up JavaScript: Working with the DOM¡·
×÷Õߣº KeeKim Heng, Google Web Developer
ÔÚÎÒÃÇ¿ª·¢»¥ÁªÍø¸»Ó¦Óã¨RIA£©Ê±£¬ÎÒÃǾ­³£Ð´Ò»Ð©javascript½Å±¾À´Ð޸ĻòÕßÔö¼ÓÒ³ÃæÔªËØ£¬ÕâЩ¹¤×÷×îÖÕÊÇDOM——»òÕß˵Îĵµ¶ÔÏóÄ£ÐÍ——À´Íê³ÉµÄ£¬¶øÎÒÃǵÄʵÏÖ·½Ê½»áÓ°Ïìµ½Ó¦ÓõÄÏìÓ¦Ëٶȡ£
DO ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ