Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resize on mouseover 2

Status
Not open for further replies.

CyClonenl

Programmer
Aug 31, 2005
3
NL
Hi!

I want to make my images resize on mouseover, is that possible?
 
Code:
<img src="image1.gif" id="img1" width="140px" height="70px" onmouseover="this.style.width='500px';this.style.height='200px'" onmouseout="this.style.width='140px';this.style.height='70px'" />
 
... but without the "px" specified in the HTML attributes. The width and height attributes for image elements should be numeric only (where pixels are the assumed unit), expect for percentages, when the % sign is allowed.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
... but without the "px" specified in the HTML attributes. The width and height attributes for image elements should be numeric only (where pixels are the assumed unit), expect for percentages, when the % sign is allowed.
But to access those elements the style collection would probably not be needed I would think, since height and width are valid attributes for the img tag.

so this:
[tt]this.style.width='500'[/tt]

would instead be this:
[tt]this.width='500'[/tt]

or I could be completely wrong, I haven't tested it

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
oh yeah, Thanks Dan.

If you have lots of images, you'd be better off calling a function to resize, probably less script in the long run.
 
Didn't in firefox 1.5, Kaht, but I didn't test it in anything else.
 
Kaht, your post got me thinking about other html tags, testing it on marquee in firefox only,

Code:
<marquee bgcolor="green" scrolldelay="100" 
onmouseover="this.behavior='alternate';this.direction='right';this.bgcolor='red';this.scrolldelay='500'">
test
</marquee>
for some reason bgcolor and scrolldelay doesn't take effect, anyone have any idea why ?.
 
I've just realised that my post could be mis-understood... To clarify, I was referring to the width and height HTML attibutes, not the width and height in the HTML style attribute.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
for some reason bgcolor and scrolldelay doesn't take effect, anyone have any idea why ?.
Hmm... not really sure. Do those attributes pass a validation test? It may be because they are no longer valid attributes (although I wouldn't see javascript being too picky about that)......

BTW, thanks for the
star.gif


-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
 
nope, infact I couldn't get the basic "<marquee>" tag to pass a validation test, to be honest I may never use it but I was curious, Thanks anyhow.
 
The marquee tag was originally an Internet Explorer only tag but a few other browsers started to support it so now it does actually render fine in most browsers (I know it works in the most recent editions of IE, FF and NS anyway) although it isn't valid HTML and won't validate. Personally, I don't like the tag but here's a reference to what it does for anyone who doesn't know:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Thanks, Ca8msm, when I did a final test the scrolldelay did work, if you typed it "this.scrollDelay" upper-case "D", but the bgcolour didn't play ball no matter what, I'm not a big fan of marquee either I just happened to pick that one for testing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top