1、禁用页面某些输入框里的右键菜单和Ctrl+V操作
Array.prototype.each=function
(iterator){
for(var i=0;i<this.length;i++ ){
try {
iterator(this [i]);
}
catch (e){
}
}
}
var Inputs=document.getElementsByTagName("input" );
var activeEleFlag=null ;
Inputs.each= Array.prototype.each;
Inputs.each(function (r){
if(!document.all&&r.getAttribute("pasteFlag")!="true" ){
r.addEventListener("focus",function(){activeEleFlag=this.tagName;},false );
r.addEventListener("blur",function(){activeEleFlag=null;},false );
}
});
document.onkeydown=function (e){
var event=window.event|| e;
if(event.ctrlKey&&String.fromCharCode(event.keyCode).toLowerCase()=="v" ){
if (document.activeElement){
var activeEle= document.activeElement;
if(activeEle.tagName.toLowerCase()=="input"&&activeEle.getAttribute("pasteFlag")!="true" ){
event.returnValue=false ;
event.cancelBubble=true ;
return false ;
}
}
else if(activeEleFlag!=null&&activeEleFlag.toLowerCase()=="input" ){
event.cancelBubble=true ;
if (event.preventDefault){
event.preventDefault();
}
return false ;
}
}
}
for(var i=0;i<this.length;i++ ){
try {
iterator(this [i]);
}
catch (e){
}
}
}
var Inputs=document.getElementsByTagName("input" );
var activeEleFlag=null ;
Inputs.each= Array.prototype.each;
Inputs.each(function (r){
if(!document.all&&r.getAttribute("pasteFlag")!="true" ){
r.addEventListener("focus",function(){activeEleFlag=this.tagName;},false );
r.addEventListener("blur",function(){activeEleFlag=null;},false );
}
});
document.onkeydown=function (e){
var event=window.event|| e;
if(event.ctrlKey&&String.fromCharCode(event.keyCode).toLowerCase()=="v" ){
if (document.activeElement){
var activeEle= document.activeElement;
if(activeEle.tagName.toLowerCase()=="input"&&activeEle.getAttribute("pasteFlag")!="true" ){
event.returnValue=false ;
event.cancelBubble=true ;
return false ;
}
}
else if(activeEleFlag!=null&&activeEleFlag.toLowerCase()=="input" ){
event.cancelBubble=true ;
if (event.preventDefault){
event.preventDefault();
}
return false ;
}
}
}
2、变换页面字体大小
function
ChangeFontSize(fontsize){
var fontPara=document.getElementById('content' );
if (fontPara){
fontPara.style.fontSize=fontsize+'px' ;
if(fontsize==14 ){
var spanTags=document.getElementById('newsList').getElementsByTagName('span' );
for(iSpan in spanTags)
if(spanTags[iSpan].className=="lidate")spanTags[iSpan].style.fontSize="10px" ;
}
if(fontsize==10 ){
var liTags=document.getElementById('newsList').getElementsByTagName('li' );
for(i=0 ;i<liTags.length;i++ ){
liTags[i].style.lineHeight="180%" ;
}
}
}
}
var fontPara=document.getElementById('content' );
if (fontPara){
fontPara.style.fontSize=fontsize+'px' ;
if(fontsize==14 ){
var spanTags=document.getElementById('newsList').getElementsByTagName('span' );
for(iSpan in spanTags)
if(spanTags[iSpan].className=="lidate")spanTags[iSpan].style.fontSize="10px" ;
}
if(fontsize==10 ){
var liTags=document.getElementById('newsList').getElementsByTagName('li' );
for(i=0 ;i<liTags.length;i++ ){
liTags[i].style.lineHeight="180%" ;
}
}
}
}
3、一段插入Flash代码的JS代码
function
i(ur,w,h){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'"> ' );
document.write('<param name="movie" value="' + ur + '">' );
document.write('<param name="quality" value="high"> ' );
document.write('<param name="wmode" value="transparent"> ' );
document.write('<param name="wmode" value="opaque"> ' );
document.write('<param name="menu" value="false"> ' );
document.write('<embed src="' + ur + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" wmode="transparent"></embed> ' );
document.write('</object> ' );
}
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'"> ' );
document.write('<param name="movie" value="' + ur + '">' );
document.write('<param name="quality" value="high"> ' );
document.write('<param name="wmode" value="transparent"> ' );
document.write('<param name="wmode" value="opaque"> ' );
document.write('<param name="menu" value="false"> ' );
document.write('<embed src="' + ur + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" wmode="transparent"></embed> ' );
document.write('</object> ' );
}