var init = function(iframId,r_v_data){
a = r_v_data;
get_Ifram(iframId);
}
var get_Ifram = function(iframId){
var iframe = document.getElementById(iframId);
get_R_V(iframe.contentWindow.document);
if (iframe.attachEvent) {
iframe.attachEvent("onload", function () {
get_R_V(iframe.contentWindow.document);
});
} else {
iframe.onload = function () {
get_R_V(iframe.contentWindow.document);
};
}
}
var get_R_V = function(obj){
dfs(obj.body);
}
function dfs(node) {
if(node.nodeType === 1) {
var tagName = node.tagName;
if(node.getAttribute('R_V') != null){
if(a.indexOf(node.getAttribute('R_V'))==-1){
node.remove();
}
}
var children = node.childNodes;
for(var i = 0, len = children.length; i < len; i++) {
dfs(children[i]);
}
}
}
参数介绍:
init初始化函数
iframId ifram的ID
r_v_data 可以传个空字符
自定义标签是R_V 获取之后吧控件给移除