Difference between revisions of "Javascript"

From Wikicliki
Jump to: navigation, search
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
I am a javascript noob. I have no idea what is going on.
+
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 :
 +
<pre>
 +
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=/';
 +
}
 +
</pre>
 +
 
  
 
== document.write ==
 
== document.write ==
Line 9: Line 37:
 
document.write(''+text+'') // - prints Hello</pre>
 
document.write(''+text+'') // - prints Hello</pre>
  
== Array ==
+
== Blur/Focus ==
  
ARGHAGHGHHGHHHHHHHHHHHHHHHHHHHHHH
+
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 ==
 
== See Also ==
  
 
*http://www.comptechdoc.org/independent/web/cgi/javamanual/javadocument.html
 
*http://www.comptechdoc.org/independent/web/cgi/javamanual/javadocument.html
 +
*[[JQuery]]
 +
*[[JQuery Sandbox]]
 +
*[[Javascript Sandbox]]
 +
*[[Actionscript-Javascript Interaction]]
 +
 +
 +
[[Category:Programming]]

Latest revision as of 08:46, 30 December 2015

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