Few days before I got a task to suggest the best hosting for the WordPress website. The website will be for USA users, so we needed to host the website in USA datacenters. I always was using OVH VPS but this client did not have who will set up this VPS and take care of it.
Continue readingCategory: Html/CSS/JavaScript
HTML Entities & Special Characters
Sometimes need special character and you did not know how to write it in code. Here is most common list of HTML entities with their numbers and names.
Equal div column heights
Sometimes we need to do equals columns. I think most all of you do it with javascript, but that’s a whole lot of code.The same result can be achieved with just a few lines of css. Here is a demonstration on Bootply:
http://www.bootply.com/QOfKYIVeGF
Html select custom style
Some time we need to style select box. Here I will show you simple example how to do this. For example we have simple select box html:
How do you cache an image in Javascript?
Once an image has been loaded in any way into the browser, it will be in the browser cache and will load much faster the next time it is used whether that use is in the current page or in any other page as long as the image is used before it expires from the browser cache.
How to disable backspace in browser?
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; }
Styles to reset css for all browsers
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.
Center align with float left or right
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.
Live image stream from ip camera
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. 🙂
Scroll to anchor with jQuery
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.