Simple several lines of JS code to achieve IE mail forwarding Sina Weibo _javascript tips

Source: Internet
Author: User
Recently opened Sina scarf, whim, want to do a browser plug-in to achieve text news, such as the forwarding of the plug. This thought should use C + + to write a plug-in (C # so big Shell sometimes really let a person headache), but Google a bit, the luck really good, search, a few about IE plug-in development. Using JavaScript, and adding the registry can be completely done. Plugins are written in JavaScript, which is not to say that the browser itself is supported without additional installation. Add registry manually can add, but trouble so write a batch handle.

1: Add registry: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\menuext\<menu text> Set default value to HTML file path, Add value contexts to) 0xf3.

2:code: Explained in MSDN http://msdn.microsoft.com/en-us/library/aa753589 (v=vs.85). aspx. MSDN Original: Set The default value of the key to the URL of the "page that contains" script you want the context menu entry to Execute. This script can obtain to the parent window object, the screen where the context menu item is executed, from the Menuargumen TS property of the external object.

Presumably, we can use the Window.external.menuArguments object to get the internal information, such as window,document these commonly used objects. So we can start right away, three to five and two minutes to get it done (the code is simple and straightforward):

Copy Code code as follows:

<script LANGUAGE = "JavaScript" >
var owindow = window.external.menuArguments;
var odocument = owindow.document;
var oselect = odocument.selection;

var oselectrange = Oselect.createrange ();
var snewtext = oselectrange.text;//.substring (0,140);

var title=snewtext.length = = 0?odocument.title:snewtext;
if (title.length>0) {
Owindow.open ("http://service.weibo.com/share/share.php?title=" +encodeuricomponent (title) + "&url=" + encodeURIComponent (Odocument.url) + "&source=" +encodeuricomponent ("broken

Wolf ") +" &appkey=1027675428&sourceurl= "+encodeuricomponent (Odocument.url));
}
</SCRIPT>


Look at an effect:



Disadvantage: Here is simply the content of this value below, has not found the way to get the selected HTML or object, is looking for, if you know please do not hesitate to enlighten. I am going to be able to parse out videos, pictures, etc., to send.

Download "Direct Click Batch operation, restart IE"

Reference documents:

http://msdn.microsoft.com/en-us/library/aa753589 (v=vs.85). aspx
Http://blogs.msdn.com/b/oldnewthing/archive/2004/05/24/140283.aspx

Related Article

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.