点点滴滴(JavaScript)
禁止选择
unselectable="on"(off): IE/Opera
style="-moz-user-select:none": FireFox(JS:element.style.MozUserSelect = "none";)
style="-khtml-user-select:none": Safari(JS:element.style.KhtmlUserSelect)
onselectstart="return false": IE
取消选择
if(document.selection && document.selection.clear) document.selection.clear(); // IE
else if(window.getSelection && window.getSelection().removeAllRanges) window.getSelection().removeAllRanges(); // FireFox/Opera/Safari
当前焦点是哪个控件
document.activeElement // IE, FF3.0+
获取样式的实际属性值
IE: 对象.currentStyle.需要访问的属性
W3C: window.getComputedStyle("对象",null).需要访问的属性(第2个参数为伪元素,如:hover,:first-letter,:before等,是必须的)
function getStyle(element, style){
var strValue = "";
if(document.defaultView && document.defaultView.getComputedStyle){
strValue = document.defaultView.getComputedStyle(element, "").getPropertyValue(strCssRule);
}
else if(element.currentStyle){
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
return p1.toUpperCase();
});
strValue = element.currentStyle[strCssRule];
}
&
相关文档:
1.javascript与Html中的调用问题。
在javascript中要想更改html中的一些属性值,特别是在页面内容较多时,务必使用document.getElementById(id)的方式进行,否则javascript将不能更改属性!
2.Date类。
在Date类中的getMonth()等方法返回值为number。因此可以使用数组存储月份信息如month=[“1月”,&ldq ......
Javascript实例:Select的OnChange()事件
我们用Select的onchange事件时,常会遇到这样一个问题,那就是连续选相同一项时,不触发onchange事件.你得有Change(改变),才能触发该事件
<select name=sel onchange="bao(this.options[this.options.selectedIndex].value)">
<option va ......
像上面的一张图片我们该怎么用js 和css + div 很好的应用到我们的项目中呢?
<style>
.InpuRight{
height:20px;background:url(img/msg_bg.png) no-repeat;background-position:0px -250px;
}
.InputError{
width:20px;height:20px;background:url(img/msg_bg.png) no-repeat 0px 0px;
}
.inputLogin{
wid ......
原文地址:http://blog.zenw.org/index/view/id/8
就在刚才,使用GOOGLE查看明天的天气,看到了GOOGLE为纪念《吃豆超人》30周年而更新的《吃豆超人》JavaScript LOGO游戏。很有意思。而且还支持双打(原来的“手气不错”按钮被设置为了双打启动按钮“Insert Coin”)。来试试吧。
如下图
刚刚进入后 ......
不知道怎么回事,以前用setTimeout没出过问题,这次怎么用都错
代码:
window.onload=function(){
function x(){
alert("s");
}
setTimeout("x()",1000);
}
把window.onload=function(){}去掉就能用了,但是这样写惯了,而且去掉之后,像document.getElementById这样的方法会找不到对象, ......