Javascript运行时错误:无法设置未定义或空引用的css Text属性 [英] Javascript runtime error:unable to set css Text property of undefined or null reference

查看:408
本文介绍了Javascript运行时错误:无法设置未定义或空引用的css Text属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Javascript代码:



 function uploadComplete(sender,args){

// var imgDisplay = $ get(imgDisplay);
var imgDisplay = $(' 。imgDisplay');
// imgDisplay.src =images / async.gif;
var img = new Image();
img.onload = function(){

imgDisplay.style.cssText = 高度:50像素;宽度:50像素;
imgDisplay.src = img.src;
};
img.src = <%= ResolveUrl(UploadFolderPath)%> + args.get_fileName();
}





这个函数给我错误: Javascript运行时错误:无法设置css Text属性undefined或null参考



告诉我这是什么问题。我该如何解决这个问题

提前谢谢

解决方案

get(imgDisplay);
var imgDisplay =


' 。imgDisplay');
// imgDisplay.src =images / async.gif;
var img = new Image();
img.onload = function(){

imgDisplay.style.cssText = 高度:50像素;宽度:50像素;
imgDisplay.src = img.src;
};
img.src = <%= ResolveUrl(UploadFolderPath)%> + args.get_fileName();
}





这个函数给我错误: Javascript运行时错误:无法设置css Text属性undefined或null参考



告诉我这是什么问题。我怎样才能解决这个问题

提前谢谢


选择器返回的整个包装器对象


Javascript Code:

function uploadComplete(sender, args) {

           //   var imgDisplay = $get("imgDisplay");
           var imgDisplay = $('.imgDisplay');
           //    imgDisplay.src = "images/async.gif";
           var img = new Image();
           img.onload = function () {

               imgDisplay.style.cssText = "height:50px;width:50px";
               imgDisplay.src = img.src;
           };
           img.src = "<%=ResolveUrl(UploadFolderPath) %>" + args.get_fileName();
       }



this function give me the error:Javascript runtime error:unable to set css Text property of undefined or null reference

Tell me whats the problem.and how can i solve this problem
Thanks in advance

解决方案

get("imgDisplay"); var imgDisplay =


('.imgDisplay'); // imgDisplay.src = "images/async.gif"; var img = new Image(); img.onload = function () { imgDisplay.style.cssText = "height:50px;width:50px"; imgDisplay.src = img.src; }; img.src = "<%=ResolveUrl(UploadFolderPath) %>" + args.get_fileName(); }



this function give me the error:Javascript runtime error:unable to set css Text property of undefined or null reference

Tell me whats the problem.and how can i solve this problem
Thanks in advance


The whole wrapper object returned by the selector


这篇关于Javascript运行时错误:无法设置未定义或空引用的css Text属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆