得不到对象值 本帖最后由 VirusFu 于 2010-05-03 16:43:31 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 因为left, right, top, bottom只有设置了position才会生效 document.getElementById('d1').style.left这种写法只支持内联样式,可以这样写function getType(o){ var t; return ((t = typeof(o)) == 'object' ? o == null && 'null' || (Object.prototype.toString.call(o)).slice(8,-1) : t).toLowerCase(); } function css(o,name){ if(this.getType(name) == 'string'){ if(o.style[name]) return o.style[name]; if(o.currentStyle) return o.currentStyle[name]; if(document.defaultView) return document.defaultView.getComputedStyle(o,"")[name]; }else if(this.getType(name) == 'object'){ for(var i in name){ o.style[i] = name[i]; } } } alert(document.getElementById('d1'),'left') document.getElementById('d1').style.left这种写法只支持内联样式也就是说必须使用style属性,才可以获取到 楼上的,必须用style属性才可以 有能力你就来!JS效果高分求方法! js如何如何判断鼠标的移动 MyEclipse里写JS脚本为什么点不出属性? 新手求助!求4个随即不重复数! 我想用window.open方法打开一个新的窗口,然后向新窗口中用javascript代码动态添加html,我该怎么办? 谁有动态添加和删除节点的好例子啊!!急用,跪谢了!!!!!!!!!!!!!!! javascript提示错误:Automation服务器不能创建对象。 请问用js如何获得当前的id名? 如何实现在提交表单之后跳转到指定页面?拜托。 input 缺少对象 javescript批量操作服务器控件值的问题 请问这句话啥意思?
function getType(o){
var t;
return ((t = typeof(o)) == 'object' ? o == null && 'null' || (Object.prototype.toString.call(o)).slice(8,-1) : t).toLowerCase();
}
function css(o,name){
if(this.getType(name) == 'string'){
if(o.style[name]) return o.style[name];
if(o.currentStyle) return o.currentStyle[name];
if(document.defaultView) return document.defaultView.getComputedStyle(o,"")[name];
}else if(this.getType(name) == 'object'){
for(var i in name){
o.style[i] = name[i];
}
}
}
alert(document.getElementById('d1'),'left')
也就是说必须使用style属性,才可以获取到