开发者

Javascript image enlarger question

So I tried using this script:

http://javascript.internet.com/miscellaneous/thumbnail.html

I've successfully generated the said img attributes on my website, however it does not seem to work. When I click on the image, nothing happens.

The generated script looks like this:

<img ondbclick="javascript:photo_6969.height=80px;
photo_6969.width=150px" onclick="javascript:photo_6969.height=241px;
photo_6969.width=450px" name="photo_6969" 
src="-----" height="80px" width="150px开发者_StackOverflow">

It is exactly the same as on the script, but it does not seem to work at all. I just need a simple image enlarger script.

My firefox error console says this:

Error: identifier starts immediately after numeric literal
Source File: ----------------
Line: 1, Column: 29
Source Code:
javascript:photo_6969.height=241px;photo_6969.width=450px

(I've ----- out the image links)


Try

<img ondblclick="this.height=80;this.width=150" onclick="this.height=241;this.width=450" src="-----" height="80px" width="150px" />

demo http://jsfiddle.net/gaby/caAvW/


changes made

  1. do not use px at the end, just the number
  2. use this. instead of the name (photo_6969.) you have applied.
  3. ondbclick should really be ondblclick


ondblclick, not ondbclick. Also width and height attributes of dom elements are integers, they do not have "px" appended.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜