»
Tiếng AnhTiếng PhápTiếng Việt

In - Cảnh cáo khi click chuột phải - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Vui nhộn » Cảnh cáo khi click chuột phải
URL: http://www.javascriptbank.com/loop-alert-on-right-click.html

Cảnh cáo khi click chuột phải © JavaScriptBank.comKhi click chuột phải đầu tiên bạn sẽ bị cảnh cáo. Nếu lì lợm click thêm lần nữa thì "dính đòn" luôn.

Phiên bản đầy đủ: jsB@nk » Vui nhộn » Cảnh cáo khi click chuột phải
URL: http://www.javascriptbank.com/loop-alert-on-right-click.html



JavaScript
<script language="javascript">var Fat = { make_hex : function (r,g,b) {  r = r.toString(16); if (r.length == 1) r = '0' + r;  g = g.toString(16); if (g.length == 1) g = '0' + g;  b = b.toString(16); if (b.length == 1) b = '0' + b;  return "#" + r + g + b; }, fade_all : function () {  var a = document.getElementsByTagName("*");  for (var i = 0; i < a.length; i++) {   var o = a[i];   var r = /fade-?(\w{3,6})?/.exec(o.className);   if (r) {    if (!r[1]) r[1] = "";    if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]);   }  } }, fade_element : function (id, fps, duration, from, to) {  if (!fps) fps = 30;  if (!duration) duration = 3000;  if (!from || from=="#") from = "#FFFF33";  if (!to) to = this.get_bgcolor(id);  var frames = Math.round(fps * (duration / 1000));  var interval = duration / frames;  var delay = interval;  var frame = 0;  if (from.length < 7) from += from.substr(1,3);  if (to.length < 7) to += to.substr(1,3);  var rf = parseInt(from.substr(1,2),16);  var gf = parseInt(from.substr(3,2),16);  var bf = parseInt(from.substr(5,2),16);  var rt = parseInt(to.substr(1,2),16);  var gt = parseInt(to.substr(3,2),16);  var bt = parseInt(to.substr(5,2),16);  var r,g,b,h;  while (frame < frames) {   r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));   g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));   b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));   h = this.make_hex(r,g,b);   setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay);   frame++;   delay = interval * frame;  }  setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay); }, set_bgcolor : function (id, c) {  var o = document.getElementById(id);  o.style.backgroundColor = c; }, get_bgcolor : function (id) {  var o = document.getElementById(id);  while(o) {   var c;   if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");   if (o.currentStyle) c = o.currentStyle.backgroundColor;   if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; }   o = o.parentNode;  }  if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF";  var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);  if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));  return c; }}// Created by: Simon Willison// http://simon.incutio.com/archive/2004/05/26/addLoadEventfunction addLoadEvent(func) {  var oldonload = window.onload;  if (typeof window.onload != 'function') {    window.onload = func;  } else {    window.onload = function() {      if (oldonload) {        oldonload();      }      func();    }  }}addLoadEvent(function() {  Fat.fade_all();});</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<p id="paragraph1" class="fade-bfdcff">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p><p id="paragraph2" class="fade-fff4bf">Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues.</p><p id="paragraph3" class="fade">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p><div style="width: 50%; text-align: left;"><P><STRONG>Basic:</STRONG></P><P>Choose the element, such as a paragraph, you would like to spotlight and give it a class of "fade":</P><P><P class=fade id=paragraph1>Watch me fade</P><P></P><P>The paragraph will fade from the default color of yellow (<CODE>#FFFF33</CODE>) to whatever it's native background color is.</P><P><STRONG>Advanced</STRONG></P><P>Change the default fade from color:</P><P><CODE>&lt;p id="paragraph1" class="fade-0066FF"&gt;Watch me fade from Blue&lt;/p&gt;</CODE></P><P>Fade an element after the page load from a script (such as after an Ajax transaction):</P><P><CODE>Fat.fade_element("paragraph1")</CODE></P><P>The <CODE>Fat.fade_element()</CODE> function accepts several arguments: <CODE>Target ID</CODE>, <CODE>Frames Per Second</CODE>, <CODE>Fade Duration</CODE>, <CODE>Fade Color</CODE>, <CODE>Final Color</CODE>.</P><P>For example, if you wanted to fade <CODE>paragraph1</CODE> from red to green at 60 frames per second for 10 seconds:</P><P><CODE>Fat.fade_element("paragraph1", 60, 10000, "#FF0000", "#00CC00")</CODE></P><P>Please note, the ID of the element is a required argument. As such all elements that you wish to fade (even by class) must have some unique ID. The ID can be anything.</P></div><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->