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
Ïà¹ØÎĵµ£º
1. ¿Í»§¶Ë //Ö÷ÒªÕë¶Ô±¾µØIEä¯ÀÀÆ÷·ÃÎÊ
<script
language="javascript">
function FileExist()
{
var sfso=new
ActiveXObject("Scripting.FileSystemObject");
var fPath="[The path of the
file]";
if(sfso.FileExists(fP ......
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 ......
¸ø Java SE ×¢Èë½Å±¾ÓïÑԵĻîÁ¦
Mustang µÄ½Å±¾ÓïÑÔÐÂÌØÐÔ
ÎĵµÑ¡Ïî
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
¼¶±ð£º Öм¶
Îâ 玥ò« (wuyuehao@cn.ibm.com), Èí¼þ¹¤³Ìʦ, IBM
2006 Äê 10 ÔÂ 30 ÈÕ
ÔÚ¼´½«·¢²¼µÄ Java SE6£¨Mustang£©ÖУ¬Ôö¼ÓÁ˶Խű¾ÓïÑÔµÄÖ§³Ö¡£Í¨¹ý¶Ô½Å± ......
10¸öÓÅÐãµÄAjaxºÍJavascript¹úÍâ×ÊÔ´ÍøÕ¾
×ªÔØµØÖ·£ºhttp://www.zzsky.cn/build/content/1246.htm
1¡¢Ajax Rain: http://www.ajaxrain.com
¡¡¡¡AjaxRainÓкܶàÍêÃÀÕûºÏAjax¡¢CSS¡¢DHTML»òJavascriptµÄʵÀý£¬ÓÐһЩDemoµÄÈ·ÖµµÃÄãÈ¥¿´Ò»¿´£¬¼´Ê¹Äã²»ÊÇÍøÒ³Éè¼Æ£¨¿ª·¢£©Ê¦¡ ......