2012-12-30 27 views
0

使用crossrider,是否有可能在dom中獲取鏈接對象並更改鏈接的標題。 我正在創建一個檢測惡意網站的插件,並在鏈接前添加[惡意]。Crossrider:更改鏈接的標題

我可能可以通過解析字符串來實現這一點,但如果DOM支持它,它會讓我的生活變得更加輕鬆。

回答

4

Crossrider擴展支持的jQuery($)對象,因此你可以用它來從extension.js文件中獲取你的鏈接,如下所示:

appAPI.ready(function ($) { 
    // Where <linkSel> is the selector for retrieving the link or links you require 
    $(<linkSel>).text(); // retrieves the text for the specified <linkSel> object 

    // OR the following to prefix the link's text with '[Malicious] ' 
    $(<linkSel>).text('[Malicious] ' + $(<linkSel>).text()); 
});