Skip to content

Instantly share code, notes, and snippets.

@kentliau
Created April 15, 2013 06:00
Show Gist options
  • Save kentliau/5385993 to your computer and use it in GitHub Desktop.
Save kentliau/5385993 to your computer and use it in GitHub Desktop.
Span a window to stretch your computer
function openWindow(){
var x = Math.floor(Math.random()*1600);
var y = Math.floor(Math.random()*800);
var px = Math.floor(Math.random()*1600);
var py = Math.floor(Math.random()*800);
/*
A fix would be adding '0' to the left of the random numbers in case its length is less than 6
'#'+ ('000000' + Math.floor(Math.random()*16777215).toString(16)).slice(-6);
or, whit the bitwise formula from the comments, it would be
'#'+ ('000000' + (Math.random()*0xFFFFFF<<0).toString(16)).slice(-6);
*/
var rColor = '#'+ ('000000' + (Math.random()*0xFFFFFF<<0).toString(16)).slice(-6);
var spec = "width=" + x + ",height=" + y + ",location=0" + ",left=" + px + ",top=" + py;
myWindow=window.open('','',spec);
myWindow.document.write("<p style='font-size:3em;'>"+ rColor +"</p>");
myWindow.document.bgColor = rColor;
myWindow.focus();
}
openWindow();
//toClearInterval = setInterval(openWindow,1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment