asp.net - Microsoft JScript 运行时错误 : Object expected

标签 asp.net scripting javascript

这行代码有问题:

changeimage('image1', 'Photos/Customers/Test1/Dock.jpg')

怎么了?

编辑: Javascript:

function changeImage(image_name, image_src) {
    document[image_name].src = image_src; 
}

调试

 <img id="ctl00_Main_gridThumbnails_ctl06_tb1" src="Photos/Customers/Test1/Forest-tn.jpg" style="border-width:0px;" />
                        <input type="hidden" name="ctl00$Main$gridThumbnails$ctl06$photolink" id="ctl00_Main_gridThumbnails_ctl06_photolink" value="~/Photos/Customers/Test1/Forest.jpg" />

最佳答案

如果您的代码与您向我们展示的完全一样,那么问题似乎出在大小写上。您已使用大写字母“I”定义了 changeImage,但您使用小写字母“i”调用了 changeimage

尝试更改为:

changeImage('image1', 'Photos/Customers/Test1/Dock.jpg');

如果您的 Javascript 在不同的文件中,也有可能是您指向该文件的链接已损坏且无法加载。

关于asp.net - Microsoft JScript 运行时错误 : Object expected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2546277/

相关文章:

user-interface - R 脚本 : Determine whether the script is run in the GUI or from command line

javascript - 这段代码在javascript中的含义是什么

javascript - 在 Chrome 扩展程序中,如何从用户的 Chrome 浏览器中准确检索用户的地区/地区/国家?

javascript - 如何获取所选菜单项的模型

asp.net - 防止输入按钮提交表格的干净方法

asp.net - Razor View - 在 Doctype 标记外发出 html

c# - Parameter.addwithvalue - ExecuteReader : CommandText property has not been initialized

c# - 这两种方法有什么区别?

linux - 如何通过匹配 shell 脚本中的模式来组合两行

powershell - 将输入的数字修改为特定的模式格式?