点点滴滴(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];
}
&
相关文档:
像上面的一张图片我们该怎么用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 ......
<title>JavaScript切换图片</title>
<script>
function showDaTu(src){
document.getElementById("defaultImg").src=src;
}
</script>
<img src="/jscss/demoimg/wall1.jpg" id="defaultImg">
<br><br><br>
<img src='/jscss/demoimg/wall_s1.jpg' onmouseover ......
直接上例子:
<html>
<script language = "javascript">
var msg = "全局变量";
function show(){
msg = "局部变量";
}
show();
alert(msg);
</script&g ......
不知道怎么回事,以前用setTimeout没出过问题,这次怎么用都错
代码:
window.onload=function(){
function x(){
alert("s");
}
setTimeout("x()",1000);
}
把window.onload=function(){}去掉就能用了,但是这样写惯了,而且去掉之后,像document.getElementById这样的方法会找不到对象, ......