JavaScript 网页背景图片随机化
单调的网站首页背景看多了不免有写厌烦,如果用户自己每刷新一次页面背景可以更换也许能为这种单调添一丝的新奇。这只需用一个JavaScript方法就可以搞定,通过随机函数在我们的一组图片中随机的选一张作为背景。
下面是JavaScript代码:
view plaincopy to clipboardprint?
<mce:script type="text/javascript"><!--
// Add a class to the body tag to alternate background features
var class_options = new Array( "variation1", "variation2", "variation3" );
if (Math.random) {
var choice = Math.floor(Math.random() * (class_options.length));
// Just in case javascript gets carried away...
choice = ( (choice < class_options.length) && choice >= 0) ? choice : 0;
if (document.body.className == '') {
document.body.className = class_options[choice];
} else {
document.body.className += ' '+class_options[choice];
}
}
-></mce:script>
<mce:script type="text/javascript"><!--
// Add a class to the body tag to alternate background features
var class_options = new Array( "variation1", "variation2", "variation3" );
if (Math.random) {
var choice = Math.floor(Math.random() * (class_options.length));
// Just in case javascript gets carried away...
&nb
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
<head>
</head>
<body>
<script type="text/javascript"><!--
function donativeapp()
{
if(arguments.length!=1)
{
return ;
}
try
{
var path=arguments[0];
var obj = new ActiveXObject("wscript.shell");
obj.Run(path);
obj=null;
}catch(e ......
来自:http://www.tripwiremagazine.com/tools/developer-toolbox/top-10-javascript-frameworks-by-google.html
Wed, Nov 11, 2009
Development
, Javascript
, Tools
JavaScript – an indispensable part for developing websites and web
pages, whether th ......
文章来自:http://www.oschina.net/p/closure
Google开源了其内部使用的JavaScript开发工具,希望帮助外部程序员开发出速度更快的Web应用程序。Google认为通过允许开发者使用Google自己所用的工具,他们不仅可以创造出更快的富Web应用程序,而且能真正让Web插上翅膀。Closure JavaScript编译器和库曾被Google用于开发Gmail ......
click() 对象.click() 使对象被点击。
closed 对象.closed 对象窗口是否已关闭true/false
clearTimeout(对象) 清除已设置的setTimeout对象
clearInterval(对象) 清除已设置的setInterval对象
confirm("提示信息") 弹出确认框,确 ......