Some it is necessary to disable backspace button in browser. This javascript code can help to disable backspace:

document.onkeydown = function () {
 var e = event || window.event;
 var keyASCII = parseInt(e.keyCode, 10);
 var src = e.srcElement;
 var tag = src.tagName.toUpperCase();
 if(keyASCII == 13) {
  return false;
 }
 if(keyASCII == 8) {
  if(src.readOnly || src.disabled || (tag != "INPUT" && tag != "TEXTAREA")) {
   return false;
  }
  if(src.type) {
   var type = ("" + src.type).toUpperCase();
   return type != "CHECKBOX" && type != "RADIO" && type != "BUTTON";
  }
 }
 return true;
}

The goal of a reset stylesheet is to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on.

The reset styles given here are intentionally very generic. There isn’t any default color or background set for the body element, for example. I don’t particularly recommend that you just use this in its unaltered state in your own projects. It should be tweaked, edited, extended, and otherwise tuned to match your specific reset baseline. Fill in your preferred colors for the page, links, and so on.

Continue reading

Some said that you cannot centre floated elements but this is not quite true. It’s true that usually you can only float left or float right but if you have a group of buttons (for example it is menu) and you want them to be fluid in width then it would be nice to have them all float in the centre of the page. There is no problem if the floats have a width because you can then ascertain the main parents width and use margin:auto to center the whole block. However that means that the floats cannot be a fluid width (i.e. shrinkwrap their content) or you would have to class each individual element and apply a different width to each which is a little unsatisfactory.

Continue reading

Yesterday I had a task make stream images from ip camera. IP camera always put images to the same directory with same image name. This is a source code, whick can do this.

var tick=0;
image=new Image();
reload = new Date();
reload = reload.getTime();
image.src="http://your_domain.lt/camera/image.jpg?nocache="+reload;

function refreshCam()
{
tick++;
if(tick>3){restart=1;} else {restart=0;}
if(image.complete)
{
tick=0;
document.images["webcam"].src = image.src;
image=new Image();
reload = new Date();
reload = reload.getTime();
window.status = "";
image.src="http://your_domain.lt/camera/image.jpg?nocache="+reload;
}
if(restart)
{
tick=0;
image=new Image();
reload = new Date();
reload = reload.getTime();
window.status = "";
image.src="http://your_domain.lt/camera/image.jpg?nocache="+reload;
}
window.status = window.status + ".";
setTimeout("refreshCam()", 1000);
}
refreshCam();

And this is html code for this script


<IMG NAME="webcam" SRC="hhttp://your_domain.lt/camera/image.jpg" BORDER=0/>

This script refresh image once in a second. If you want to change time, you can do it in function setTimout(). 1000 is one second.

I hope, it will help for someone. 🙂

Today I needed to create link with anchor. When I pushed it, it opens new page and add class to div. The source code is:

var class= window.location.href.slice(window.location.href.indexOf('#') + 1).split('#');
if(class){
jQuery('.testimonial_cont').find('.'+class).show('slow');
jQuery('html,body').animate({scrollTop: jQuery('.testimonial_cont').find('.'+class).parent().offset().top},'slow');
}

Of course you can change slow to normal or fast or even a int in milliseconds.

I hope it will help for someone.