今天在学校的一个页面里,发现此页面竟然把右键单击给禁用了。
遂翻出页面代码,发现只是<body>节点里简单的加入了
- oncontextmenu="return false" onselectstart="return false"
- 1.
Remove tag’s all attributtes;
- function removeAllAttr(id){
- // var node = document.getElementsByTagName(tag)[0];
- var node = document.getElementsById(id);
- if(node){
- var attr = node.attributes;
- while(attr.length){
- node.removeAttribute(attr[attr.length-1].nodeName)
- }
- }
- }
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
= = = = = = = = = = = = = = = = = =
使用jQuery的方法(网上copy的):
- $("selector").each(function() {
- // first copy the attributes to remove
- // if we don't do this it causes problems
- // iterating over the array we're removing
- // elements from
- var attributes = $.map(this.attributes, function(item) {
- return item.name;
- });
- // now use jQuery to remove the attributes
- var tag = $(this);
- $.each(attributes, function(i, item) {
- tag.removeAttr(item);
- });
- });
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.