Javascript

From Wikicliki
Jump to: navigation, search

What is going on.

Fullscreen

the [NHS flu site http://www.immunisation.nhs.uk/Vaccines/Flu] resized itself to the fullest biggest width of the browser window. irregardless of how big it was.

/js/size.js :

var pixelsPerEm;
window.onresize = rze;

function lde() {
 	pixelsPerEm = document.getElementById('sizer').offsetWidth;
	var date = new Date();
	date.setTime(date.getTime()+(60*60*1000));
	document.cookie = 'pixelsperem='+pixelsPerEm+'; path=/';
	rze();

}

function rze() {
	document.body.style.fontSize = (100/((48.5*pixelsPerEm)/document.body.offsetWidth))+"%";
	var date = new Date();
	date.setTime(date.getTime()+(60*60*1000));
	document.cookie = 'textsize='+document.body.style.fontSize+'; path=/';
}


document.write

document.write("Hello") // - prints Hello
var text="Hello"
document.write(''+text+'') // - prints Hello
var text="Hello"
document.write(''+text+'') // - prints Hello

Blur/Focus

Focus: puts the cursor in that box to begin with.


Simple HTTP Server

In Mac OS X you can run the following 2 commands: > cd /path/to/project/folder > python -m SimpleHTTPServer 8080

go to http://localhost:8080 to see the site you can change the port to another number

See Also