Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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»ñÈ¡µ±Ç°Îļþȫ·¾¶¡¢µ±Ç°Ä¿Â¼¡¢µ±Ç°ÎļþÃû

//»ñÈ¡µ±Ç°Îļþȫ·¾¶
<script language="javascript"> 
alert(window.location.href); 
alert(window.location); 
alert(location.href); 
alert(parent.location.href); 
alert(top.location.href); 
alert(document.location.href); 
alert(document.URL);
</scri ......

JavaScriptÎļþ²Ù×÷

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

C#ѧϰ¼°ÓëdelphiµÄ±È½Ï£¨¶þ£©

      C#µÄToolTip£¨delphi½ÐHint£©»úÖÆ·Ç³£¹Ö£¬²»ÊÇÏñdelphiµÄÔª¼þÒ»Ñù£¬Ã¿¸öTControlÓÐÒ»¸öHintÊôÐÔ£¬C#ÓÐÒ»¸öToolTipÔª¼þ£¬µ±°ÑÕâ¸öÔª¼þ´Ó¹¤¾ßÏäÀ­µ½formÉϺó£¬Ñ¡ÖÐformÉϵÄÈκÎcontrolÔª¼þ£¬ÔÚÊôÐÔ´°Ì壨Object Inspector£©ÉϾͻá¶à³öÒ»¸öÊôÐÔ“toolTip1ÉϵÄToolTip”£¬Èç¹û¶àÀ­¼¸¸ ......

10¸öÓÅÐãµÄAjaxºÍJavascript¹úÍâ×ÊÔ´ÍøÕ¾

10¸öÓÅÐãµÄAjaxºÍJavascript¹úÍâ×ÊÔ´ÍøÕ¾
×ªÔØµØÖ·£ºhttp://www.zzsky.cn/build/content/1246.htm
        1¡¢Ajax Rain: http://www.ajaxrain.com
¡¡¡¡AjaxRainÓкܶàÍêÃÀÕûºÏAjax¡¢CSS¡¢DHTML»òJavascriptµÄʵÀý£¬ÓÐһЩDemoµÄÈ·ÖµµÃÄãÈ¥¿´Ò»¿´£¬¼´Ê¹Äã²»ÊÇÍøÒ³Éè¼Æ£¨¿ª·¢£©Ê¦¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ