Nov
3

Creating overlay in scripty2 is very simple.

Create a button with an id mybutton. Add the javascript below at the head section of your file.

document.observe('dom:loaded', function() {
	$("mybutton").observe("click", function() {
		$(document.body).insert(S2.viewportOverlay().setStyle(
'background:#000;opacity:0.5;height:100%;'));
	});
});

Lines 3 and 4 does the overlay. If you wanted the overlay to be a bit darker, set the opacity to 0.6 or higher.

And last… the html.

<body>
<div id="mybutton">Click Me</div>
</body>

Scripty2 is still in beta as of this writing.

Browser Support
It is not working on IE versions. Tested in Firefox, Google Chrome, Opera and Safari

© 2012 · Karl Sheen Blog · Sitemap · Proudly powered by Wordpress and Twitter Bootstrap · Icons by Glyphicons