From The Blog

HTML5 Javascript: get file input upload size locally

28 October 2013, in

if (typeof FileReader !== "undefined") {
var size = document.getElementById('upload_file').files[0].size;
size = Math.round(size / 1024);
console.log(size+' KB');
}



Post a Comment

Javascript parsing issue on IE7

16 August 2012, in

I had a problem in a page that gets it's content via an ajax request and place the result of the ajax request in a slider, I was testing it on other browsers, and It came to IE, passed IE9 and IE8, and when it came to IE7 I couldn't see the slider with it's contents at all.

 

No error is shown in the console :-S, then I have figured it out......................

 

It is common in many programming languages that arrays and object attributes have a comma without the last element, and the parser/compiler/interpreter doesn't fire an error for that,



Post a Comment

Javascript: dealing with cookies

14 February 2012, in
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function eraseCookie(name) {


Post a Comment

Change page URL without refreshing page

12 October 2011, in

Can we change page URL, eg. when sending an ajax request, or opening an image in a light-box?

HTML5: Changing the browser-URL without refreshing page

Reference: http://spoiledmilk.dk/blog/html5-changing-the-browser-url-without-refreshing-page

An often overlooked feature of HTML5 is the new "onpopstate" event.



Post a Comment