Use of window.external

Source: Internet
Author: User

Because there are many times in the work need to use window.external, has been confused, and today was asked, so the assault study a bit, write down memo.
--------------------------------------
We can use Window.external.myfunc () to invoke the external method MyFunc provided by the browser in JS. You can call the C + + code in the JS script within the Web page.


IE has implemented some external methods by default, see
1: An article: http://www.it118.org/Specials/2e876829-483a-4216-a6ef-08a472c94297/8f8d0507-b4c8-4d92-8e35-3c88dade3a17.htm
2: There are more in official documents: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/external.asp


In the project that embeds the browser, in addition to the external methods provided by IE by default, the script that requires the Web page can invoke C + + code, the script extension must be implemented to achieve this interaction. Implementing a script extension is to implement a IDispatch interface in your program that returns this interface pointer through the ongetexternal virtual function of the CHtmlView class, so that you can pass the Window.external.XXX in the script (the keyword window can be omitted) To refer to methods or properties exposed by the interface (XXX is a method or property name).
Refer to "Implementing Script extensions" http://topic.csdn.net/u/20080116/17/5fbac468-1188-4c9c-9339-ad48edd8a4d3.html


Firefox and Chrome also provide external objects, for example, they all implement the OpenSearch two external methods by default:
Addsearchprovider issearchproviderinstalled
Under Chrome, you can see it in the console input window.external.
Firefox provides a slightly more external method by default, and can be seen through Firebug.


Window.external.AddFavorite This script that adds a Web site to a browser's favorites should often be seen, but you also know how to use other window.external? Because there are some commands about the operation of the system files, there are some scripts that make mistakes in the security settings.


1.external. Adddesktopcomponent site as the user's Active Desktop
Syntax: External. Adddesktopcomponent (address, type [Image/website], left distance, top distance, width, length)
function J_ADC () {//Example
Window.external.AddDesktopComponent ("Http://www.i0713.net", "website", 0,0,800,600);
}


2.external. Addfavorite Add a website to a user's favorite folder
Syntax: External. Addfavorite (URL, title);
function J_af () {
Window.external.AddFavorite (Location.href, document.title);
}


3.external. Navigateandfind Search for a field in a specified Web site
Syntax: External. Navigateandfind (file address, keyword, _target)
<script language= "JavaScript" >
function J_an () {
Window.external.NavigateAndFind ("http://www.i0713.net/IT/prog/find.asp", Gosearch.value, "");
}
</script>


4.external. Showbrowserui Call Language Selection window and Favorites Management window
Syntax: External. Showbrowserui (Type [languagedialog/organizefavorites], NULL)
<input type= "button" name= "button" value= "language setting" onclick= "Window.external.ShowBrowserUI (' Languagedialog ', null)" >
<input type= "button" Name= "Submit2" value= "Organize Favorites" onclick= "Window.external.ShowBrowserUI (' organizefavorites ', NULL) ">


5.external. ImportExportFavorites Importing and exporting user favorites
Syntax: External. ImportExportFavorites (Import/true export/false, file path)
<input type= "button" name= "button" value= "Import Favorites" Onclick=window.external.importexportfavorites (True, "http/ Www.i0713.net ");>
<input type= "button" Name= "Button3" value= "Export Favorites" Onclick=window.external.importexportfavorites (False, "HTTP/ Www.i0713.net ");>


Tantom: Worry-free script also has a similar program, you can try, but with PHP do not receive users from the collection of information, import is very simple. Useful ASP and PHP to receive the user's favorite code, ASP has not tried not to know is not available, PHP tried, but only can receive 75% of the collection of data, very strange, interested in PHP and ASP code in the forum to send a post it.


There are several usages of external, but no use, not listed.

Use of window.external

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.