2012年1月11日 星期三

[C#]讓Webbrowser中的js直接呼叫Winform的function


引用: http://www.dotblogs.com.tw/jimmyyu/archive/2009/09/24/10758.aspx

在js 裡面用 window.external 來呼叫winform的function





其他參考
http://www.iteye.com/topic/243494



========================================================

  简介:window.external.AddFavorite这个把网站添加到浏览者收藏夹的脚本大家应该常常看过,但你还知道window.external的另外一些用法呢?由于是一些关于系统文件操作的命令,因为安全设置有些脚本会出错误.

1.external.AddDesktopComponent 把网站作为用户的Active桌面

 语法:external.AddDesktopComponent(地址,类型[image/website],左距离,顶距离,宽度,长度)
  1. function j_adc(){ //例子  
  2. window.external.AddDesktopComponent("http://...","website",0,0,800,600);  
  3. }  

2.external.AddFavorite 把网站加入到用户的收藏夹

语法:external.AddFavorite(网址,标题);
  1. function j_af(){  
  2. window.external.AddFavorite(location.href, document.title);  
  3. }  

3.external.NavigateAndFind 搜索指定网站中的某个字段

语法:external.NavigateAndFind(文件地址,关键字,_Target) 
  1. function j_an(){    
  2. window.external.NavigateAndFind("http://...",gosearch.value,"");    
  3. }    

4.external.ShowBrowserUI 调用语言选择窗口与收藏夹管理窗口

语法:external.ShowBrowserUI(类型[LanguageDialog/OrganizeFavorites], null)
  1. <input type="button" name="Button" value="语言设置" onclick="window.external.ShowBrowserUI('LanguageDialog', null)">  
  2. <input type="button" name="Submit2" value="整理收藏夹" onclick="window.external.ShowBrowserUI('OrganizeFavorites', null)">  

5.external.ImportExportFavorites 导入与导出用户收藏夹

语法:external.ImportExportFavorites(导入/true 导出/false, 文件路径)
  1. <input type="button" name="Button" value="导入收藏夹" onClick=window.external.ImportExportFavorites(true,"http://...");>  
  2. <input type="button" name="Button3" value="导出收藏夹" onClick=window.external.ImportExportFavorites(false,"http://...");>  

6.external.addChanne 加入到频道

 

语法:external.addChannel(网页路径)  

7.下面是external对象所有方法列表

MethodDescription
AddChannelObsolete. Presents a dialog box that enables the user to add the specified channel, or to change the channel URL, if it is already installed.
AddDesktopComponentAdds a Web site or image to the Microsoft Active Desktop.
AddFavoritePrompts the user with a dialog box to add the specified URL to theFavorites list.
AddSearchProviderAdds a search provider to the registry.
AddService New for Internet Explorer 8User initiated action to add a service.
AddToFavoritesBar New for Internet Explorer 8Adds a URL to the Favorites Bar.
AutoCompleteSaveFormSaves the specified form in the AutoComplete data store.
AutoScanNo longer available as of Internet Explorer 7. Attempts to connect to a Web server by passing the specified query through completion templates.
BrandImageUriNot supported. Retrieves the Uniform Resource Identifier (URI) of an alternate product image.
bubbleEventPropagates an event up its containment hierarchy.
ContentDiscoveryReset New for Internet Explorer 8Resets the list of feeds, search providers, and Web Slices associated with the page.
CustomizeClearTypeNot supported. Sets a registry value to turn ClearType on or off.
CustomizeSettingsNot supported. Saves the user settings from a "first run" page.
DefaultSearchProviderNot supported. Retrieves the name of the user's default search provider.
DiagnoseConnectionNot supported. Attempts to diagnose problems with the network connection.
ImportExportFavoritesDeprecated. Handles the import and export of Internet Explorer favorites.
InPrivateFilteringEnabled New for Internet Explorer 8Detects whether the user has enabled InPrivate Filtering.
IsSearchMigratedNot supported. Determines whether autosearch settings were migrated from a previous version of Internet Explorer.
IsSearchProviderInstalledDetermines if a search provider has been installed for the current user and whether it is set as default.
IsServiceInstalled New for Internet Explorer 8Check if a service is already installed.
IsSubscribedObsolete. Retrieves a value indicating whether the client subscribes to the given channel.
NavigateAndFindNavigates to the specified URL and selects the specified text.
PhishingEnabledNot supported. Determines whether Microsoft Phishing Filter is enabled.
raiseEventTriggers an event, as specified.
RunOnceHasShownNot supported. Determines whether the "first run" page has been shown.
RunOnceRequiredSettingsCompleteNot supported. Sets a registry value to indicate whether the "first run" page completed successfully.
RunOnceShownNot supported. Sets a registry value to indicate that the "first run" page has been shown.
SearchGuideUrlNot supported. Retrieves the URL of a page that can be used to install additional search providers.
setContextMenuConstructs a context menu, as specified.
ShowBrowserUIOpens the specified browser dialog box.
SkipRunOnceNot supported. Enables the user to select "first run" settings at a later time.
SkipTabsWelcomeNot supported. Disables the welcome screen that appears when opening a new tab in Internet Explorer 7.
SqmEnabledNot supported. Determines whether Software Quality Monitoring (SQM) is enabled.
 参考:http://msdn.microsoft.com/en-us/library/ms535246%28VS.85%29.aspx

0 意見:

張貼留言

 

MangoHost Copyright © 2009 Cookiez is Designed by Ipietoon for Free Blogger Template