/    Sign up×
Community /Pin to ProfileBookmark

…again with timing mouse over effect

Sorry for posting this prob again…but I don’t know how to solve it.

I have this image, in a place holder, that changes its size on mouseover. What I wanna do is make the change slower than it is now. This is the code

<P>
<IMG onmouseover=this.width=this.width*2 onmouseout=this.width=this.width/2 src=”image.jpg” width=125>
</P>

Days ago gil davis posted this script:

<head>
<script>
var tmp = 0;
var num = 0;
var img = null;
var timer = null;

function expand(it) {
tmp = it.width; // save original size
num = 0;
img = it;
timer = setTimeout(“exp()”,100); // 100ms steps
}

function exp() {
img.width = img.width * 1.1; // 10% each time
num++
if (num < 5) // 5 steps then stop
{timer = setTimeout(“exp()”,100);}
}

function shrink(it) {
clearTimeout(timer); // stop if active
it.width = tmp; // go back to original size
}
</script>
</head>
<body>
<img src=”lilguy2.gif” onmouseover=”expand(this)” onmouseout=”shrink(this)”>
</body>

It works perfectly if I try it in Frontpage…but not when I use it in my web page built with CMS. Help please!!!!

thansk in advance
Ale ?

to post a comment
JavaScript

23 Comments(s)

Copy linkTweet thisAlerts:
@Stephen_PhilbinAug 31.2004 — I got the same problem. Needind to delay the iteration of a loop by a selected number of milliseconds to give the impression of motion rather than something being somewhere and then BAM! it's somewhere elseLavalamp explained why the settimeout() thing does not work for this in my thread.

I've been looking for something that would behave as you might expect settimeout() to work for a while now. I thought I'd got somewhere when I found "setinterval()" but that still just allowed the sudden BAM, changed thing but only allowed one of the eight things I was trying to change to be changed and also made the function take an increasingly longer time to work each time it was used.
Copy linkTweet thisAlerts:
@alexthecattaauthorAug 31.2004 — "glad" that I'm not alone with this kind of prob ? If u work it out pliz let me know how, I'll do the same...but I'm a hopeless html user?
Copy linkTweet thisAlerts:
@gil_davisAug 31.2004 — Post a link to your page.
Copy linkTweet thisAlerts:
@Stephen_PhilbinAug 31.2004 — mine is www.vagusnet.com/ptest/menu.html

It just uses a loop to increment or decrement the margin by 1px each time. So If I can have the loop delayed by 1 ms each time it should create the illusion of motion.

This is the link to my original thread too. The last post as the most recent version of the source I've been trying out.
Copy linkTweet thisAlerts:
@JPnycAug 31.2004 — Dunno, this works perfectly fine for me:

if(i<=100) {


window.document.getElementById("htm").style.filter="alpha(opacity="+i+")";

i+=10; setTimeout('ht()', 0); }

if statement 1st, then action, then increment, then recursive call with timeout.
Copy linkTweet thisAlerts:
@alexthecattaauthorAug 31.2004 — I can't post the link to my page...it's an intranet.

I'll try tomorrow your new suggetion.

good night
Copy linkTweet thisAlerts:
@alexthecattaauthorSep 01.2004 — I've done like this, it doesn't work...what I'm still doing wrong?

<P>

<if (i<=100) {

window.document.getElementById("htm").style.filter="alpha(opacity="+i+")";

i+=10; setTimeout('ht()', 0); }>

<IMG src="image.jpg" width=125 border=0></P>
Copy linkTweet thisAlerts:
@JPnycSep 02.2004 — Ok, that was an example of syntax, not exact code for your purposes. You can't put javascript inside any tag but a <script tag. I was posting that to show that the test comes 1st, then the action, then increment, then timed call of the function again. My script makes things fade, not change size.
Copy linkTweet thisAlerts:
@alexthecattaauthorSep 08.2004 — I'm still in trouble...with the same trouble.

But Iive got more details and maybe u can help me. The image with the mouse over effect is placed in a place holder, the template I'm using is given, I can't change the main structure.

Can I put a script inside a place holder? Cos up to now nothing works: I paste the script, save the page, a message about an invalid content or format appears, and then the result is na image that doesn't move on mouse over, and a part of the script appears as text in the place holder.

can u help me ?

thanks in advance.

here I encloce the script:
Copy linkTweet thisAlerts:
@alexthecattaauthorSep 08.2004 — I forgot the script, but it has been posted before
Copy linkTweet thisAlerts:
@gil_davisSep 08.2004 — Why don't you put all the files for the page (images scripts and html) into a zip file and attach the file to your next post.
Copy linkTweet thisAlerts:
@JPnycSep 08.2004 — Alex, the basic premise is this.

i=0;

if(i<3) {

//statements to increase picture size go here

i++; setTimeout('functionName()', 100);

}

That's the basic way to time a loop. Now the increase size statements you already had (if memory serves) but the logic of the timed loop was wrong. Set it up like I have above.
Copy linkTweet thisAlerts:
@alexthecattaauthorSep 08.2004 — here I send the code of the page: it gives me a script error when I try it with Frontpage, but then the animation works properly, but absolutely not when I use it in Microsoft Content management server.

[upl-file uuid=e9546c95-811e-47be-9c6f-d8978d766f1b size=8kB]page&image.zip[/upl-file]
Copy linkTweet thisAlerts:
@gil_davisSep 08.2004 — How about the CSS and SCRIPT files?
Copy linkTweet thisAlerts:
@alexthecattaauthorSep 08.2004 — sorry, what do u mean?
Copy linkTweet thisAlerts:
@gil_davisSep 08.2004 — Your zip contained an image and a text file. I assumed that the text file was actually supposed to be the web page. It has the following external links:
<i>
</i>&lt;LINK REL=STYLESHEET TYPE="text/css" HREF="/NR/EP/style/EP.css"&gt;
&lt;LINK REL=STYLESHEET TYPE="text/css" HREF="/NR/EP/style/floatleft.css"&gt;
&lt;SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="/NR/EP/js/desktop.js"&gt;&lt;/SCRIPT&gt;
&lt;SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="/NR/EP/js/tabs.js"&gt;&lt;/SCRIPT&gt;

So I expected to see four more files: EP.css, floatleft.css, desktop.js and tabs.js.
Copy linkTweet thisAlerts:
@alexthecattaauthorSep 08.2004 — that's what asked me another friend of mine. CMS doesn't allow me to do anything with these js files, I don't even see them. I just can use the given template.
Copy linkTweet thisAlerts:
@gil_davisSep 08.2004 — I don't know what else I can do to help you. There was one line in the file that threw an error and I commented it out to see what else would happen (line 44 of the file). Using IE 6, the figure expands "slowly" when I mouse over and contracts when I mouse out.

You are on your own. Sorry.
Copy linkTweet thisAlerts:
@alexthecattaauthorSep 08.2004 — don't worry, thanks for tryin to solve my probs ?

ciao
Copy linkTweet thisAlerts:
@JPnycSep 10.2004 — Problem is, Alex, most of us aren't that familiar with CMS. We only know what works in most situations we encounter, and what's supposed to work. What that MS product does, we cannot say.
Copy linkTweet thisAlerts:
@alexthecattaauthorSep 15.2004 — thanks all for trying to solve my prob.

Here I have another question: at the moment I've got this image that change its size on mouse over. the enanchement goes just in one direction, the image has an anchor point on the top left-side corner, and it grows in the opposite direction. I'd like to have the anchor point in the middle of the top side of the image, with the enanchement in both direction.

I enclose a file with a better explanation of waht I'd like to have.

the code I have now is:

<IMG onmouseover=this.width=this.width*2 onmouseout=this.width=this.width/2 src="image.jpg" width=125>

thanks in advance

ciao

Ale

[upl-file uuid=e764b0d2-9d90-4244-8a6e-7c8ac47d9491 size=3kB]explication.zip[/upl-file]
Copy linkTweet thisAlerts:
@JPnycSep 17.2004 — Then you can't use absolute or relative css positioning. They only key off left or right, top or bottom. Try floating the image instead.
Copy linkTweet thisAlerts:
@alexthecattaauthorSep 18.2004 — how can I make an image float?

sorry but u know...I'm very very rookie
×

Success!

Help @alexthecatta spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...