Added Rewrite HREFs (HTTPS) module
This module will rewrite all the href attributes of HTTPS links to use HTTP instead of HTTPS. Links relative to the web root are not rewritten. Added beef.dom.rewriteLinksProtocol(old_protocol, new_protocol, selector) git-svn-id: https://beef.googlecode.com/svn/trunk@1317 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
@@ -165,6 +165,31 @@ beef.dom = {
|
||||
}).length;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param: {String} old_protocol: the old link protocol to be rewritten
|
||||
* @param: {String} new_protocol: the new link protocol to be written
|
||||
* @param: {String} selector: the jquery selector statement to use, defaults to all a tags.
|
||||
* @return: {Number} the amount of links found in the DOM and rewritten.
|
||||
*/
|
||||
rewriteLinksProtocol: function(old_protocol, new_protocol, selector) {
|
||||
|
||||
var count = 0;
|
||||
var re = new RegExp(old_protocol+"://", "gi");
|
||||
var sel = (selector == null) ? 'a' : selector;
|
||||
|
||||
$j(sel).each(function() {
|
||||
if ($j(this).attr('href') != null) {
|
||||
var url = $j(this).attr('href');
|
||||
if (url.match(re)) {
|
||||
$j(this).attr('href', url.replace(re, new_protocol+"://")).click(function() { return true; });
|
||||
count++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return count;
|
||||
},
|
||||
|
||||
/**
|
||||
* @params: {String} id: reference identifier to the applet.
|
||||
* @params: {String} code: name of the class to be loaded. For example, beef.class.
|
||||
@@ -200,4 +225,4 @@ beef.dom = {
|
||||
|
||||
};
|
||||
|
||||
beef.regCmp('beef.dom');
|
||||
beef.regCmp('beef.dom');
|
||||
|
||||
Reference in New Issue
Block a user