admin管理员组文章数量:1334825
Something wrong with this line of code:
changeimage('image1', 'Photos/Customers/Test1/Dock.jpg')
What is wrong?
Edit: Javascript:
function changeImage(image_name, image_src) {
document[image_name].src = image_src;
}
Debug
<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" />
Something wrong with this line of code:
changeimage('image1', 'Photos/Customers/Test1/Dock.jpg')
What is wrong?
Edit: Javascript:
function changeImage(image_name, image_src) {
document[image_name].src = image_src;
}
Debug
<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" />
Share
Improve this question
edited Mar 30, 2010 at 15:13
tom
asked Mar 30, 2010 at 15:07
tomtom
412 gold badges2 silver badges4 bronze badges
3
-
Give us some more context. I would say that
changeimage
is probably not defined. – Aaron Commented Mar 30, 2010 at 15:10 -
The
changeimage
function is not found. – Josh Stodola Commented Mar 30, 2010 at 15:12 - All the javascripts are found, so it's not that – tom Commented Mar 30, 2010 at 16:06
4 Answers
Reset to default 1If your code is exactly as you have shown us, then it seems the problem lies in capitalization. You have defined changeImage
with a capital 'I', but you called changeimage
with a lower-case 'i'.
Try changing to:
changeImage('image1', 'Photos/Customers/Test1/Dock.jpg');
If your Javascript is in a different file, it's also possible that your link to that file is broken and is not getting loaded.
FirstSimilar to me, in my JScript code, I only wrongly spell the ID 'Name' to 'Nama' make the debugger unable to find the Object I have declared and it gives me this error !!
Eg code:
DDLNameSample_Delete.Attributes.Add("onchange", "javascript:return validateDropDown_NameSample('" + DDLNamaSample_Delete.ClientID + "');")
btnDelete_NameSample.Attributes.Add("onclick", "javascript:return validateDropDown_NameSample('" + DDLNameSample_Delete.ClientID + "');")
If you you can see on the First line, I have wrongly spell DDLNamaSample_Delete
instead of DDLNameSample_Delete
.
"Object expected" simply means that the code expected to find something (an object) but didn't find it.
With just that single line, it's hard to diagnose the problem. If the code is looking for some object, you have to track down where the object should have been created. In your case, make sure the function is defined somewhere before you try to call it.
I came across this error too. And seems like this error is caused due to:
- The name of the object is different than being used.
- The object it is looking for is not yet created in the document.
- Syntactical error. In my case, closing brace for "if" statement was missing. This caused the runtime error "Microsoft JScript runtime error: Object expected".
本文标签: aspnetMicrosoft JScript runtime error Object expectedStack Overflow
版权声明:本文标题:asp.net - Microsoft JScript runtime error: Object expected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742345759a2457488.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论