js常用代碼
1.?oncontextmenu="window.event.returnValue=false"?將徹底屏蔽鼠標右鍵特效<table?border?oncontextmenu=return(false)><td>no</table>?可用于Table?
2.?<body?onselectstart="return?false">?取消選取、防止復制?javascript技巧
3.?onpaste="return?false"?不準粘貼技巧
4.?oncopy="return?false;"?oncut="return?false;"?防止復制的javascirpt特效
5.<noscript>// 禁止另存為
??????<iframe src="*.htm"></iframe>
???</noscript>
功能:禁止右鍵、禁選擇、禁粘貼、禁shift、禁ctrl、禁alt
<script?language="JavaScript">
<!--
function?key(){?
???//禁止Shift
???if(event.shiftKey){
??????window.close();
???}
???//禁止Alt
???if(event.altKey){
??????window.close();
???}
???//禁止Ctrl
???if(event.ctrlKey){
??????window.close();
???}
???return?false;
}
document.onkeydown=key;
if?(window.Event)
??????document.captureEvents(Event.MOUSEUP);
function?nocontextmenu(){
???event.cancelBubble?=?true
???event.returnValue?=?false;
???return?false;
}
function?norightclick(e){
???if?(window.Event){
??????if?(e.which?==?2?||?e.which?==?3)
??????return?false;
???}
???else
??????if?(event.button?==?2?||?event.button?==?3){
????????????event.cancelBubble?=?true
????????????event.returnValue?=?false;
????????????return?false;
??????}
}
//禁右鍵
document.oncontextmenu?=?nocontextmenu;??//?for?IE5+
document.onmousedown?=?norightclick;??//?for?all?others
//-->
</script>
<body?onselectstart="return?false";?onpaste="return?false";>?
在JSP標準的語法中,如果pageEncoding屬性存在,那么JSP頁面的字符編碼方式就由pageEncoding決定,否則就由contentType屬性中的charset決定,如果charset也不存在,JSP頁面的字符編碼方式就采用默認的ISO-8859-1。
//添加到收藏夾??
function AddToFavorite()??
{??
????if (document.all){??
?????? window.external.addFavorite(document.URL,document.title);??
????}else if (window.sidebar){??
?????? window.sidebar.addPanel(document.title, document.URL, "");??
????}??
}??
??
//設為首頁??
function setHomepage(){??
????if (document.all){??
????document.body.style.behavior='url(#default#homepage)';??
????document.body.setHomePage(document.URL);??
??}else if (window.sidebar){??
????????if(window.netscape){??
?????? try{????
??????????netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");????
?????? }catch (e){????
????????????????????alert( "該操作被瀏覽器拒絕,如果想啟用該功能,請在地址欄內輸入 about:config,然后將項 signed.applets.codebase_principal_support 值該為true" );????
?????? }??
????????}????
????var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);??
????prefs.setCharPref('browser.startup.homepage',document.URL);??
????}??
}
posted on 2010-03-09 11:07 飛熊 閱讀(232) 評論(0) 編輯 收藏 所屬分類: javaScript