最近剛開(kāi)通新浪圍脖,突發(fā)奇想,想做個(gè)瀏覽器插件實(shí)現(xiàn)文字新聞等的轉(zhuǎn)發(fā)圍脖的插件。本以為應(yīng)該用C++寫(xiě)個(gè)插件的(c#那么大個(gè)殼有時(shí)真的讓人頭疼),但是google了一下,手氣真的不錯(cuò),搜到了,幾篇關(guān)于IE插件的開(kāi)發(fā)。用的Javascript,和添加注冊(cè)表就可以完全搞定。插件用javascript寫(xiě)那就不用多說(shuō),瀏覽器本身就支持的,不用額外安裝。添加注冊(cè)表手動(dòng)可以添加,但是麻煩所以寫(xiě)了一個(gè)批處理搞定。
1:添加注冊(cè)表:HKEY_CURRENT_USER/Software/Microsoft/Internet Explorer/MenuExt/<Menu Text> 設(shè)置默認(rèn)值為html文件路徑,添加值Contexts為)0xf3.
2:code : 在MSDN (v=VS.85).aspx中有所講解。MSDN原文:Set the default value of the key to the URL of the page that contains the script you want the context menu entry to execute. This script can obtain the parent window object, the screen where the context menu item was executed, from the menuArguments property of the external object.
大概就是說(shuō)我們可以用window.external.menuArguments這個(gè)對(duì)象獲取到內(nèi)部的信息,如window,document這些常用的對(duì)象。所以我們就可以馬上開(kāi)工了,三下五去二不幾分鐘就搞定(代碼很簡(jiǎn)單就直接Code了):
復(fù)制代碼 代碼如下:
<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 src="http://www.survivalescaperooms.com/uploads/allimg/130704/0914414U7_0.png">
新聞熱點(diǎn)
疑難解答
圖片精選