/    Sign up×
Community /Pin to ProfileBookmark

cross browser compat

hi everybody iwrote a little script so that when u mouser over an image it becomes the full image size but when its mouse out and its normal status its in a smaller size.

see example [URL=”http://www.clubrockrevolution.com/try/admin/session”]http://www.clubrockrevolution.com/try/admin/session[/URL]

currently it only works with IE im wondering what i have to do to make it work cross browser i.e. with FF and Operah, heres the example code:

[CODE]
<style>
div.container {
z-index:2;
position:relative;
width:200px;
height:100px;
}
div.start {
z-index:2;
position:absolute;
background-image:url(../../events/exampleimg.jpg);
width:200px;
height:100px;
}
</style>
<script language=’javascript’>
function mOver() {
document.getElementById[‘test’].style.width=500;
document.getElementById[‘test’].style.height=300;
}
function mOut() {
document.getElementById[‘test’].style.width=200;
document.getElementById[‘test’].style.height=100;
}
</script>

<table>
<tr><td>
<div class=’container’>
<div class=’start’ onMouseOver=’mOver()’ onmouseout=’mOut()’></div>
</div>
</td>
<td><div class=text>date</div>
<div class=”eventh”>title</div>
<div class=”text”>info</div>
</td></tr>
</table>
[/CODE]

p.s. i know its not as quick as say this.className = and working with css but im getting the rollover image size dynamically using php, hense im working it this way. ive taken all my php code out of the above to make it as simple as possible though. thanks in advance

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@shakeukauthorJun 08.2008 — also i relise i have missed the [COLOR="Red"]id[/COLOR] tag out but that isnt the problem.
Copy linkTweet thisAlerts:
@Declan1991Jun 08.2008 — document.getElementById[COLOR=RED]([/COLOR]'test'[COLOR=RED])[/COLOR]
I'm amazed that document.getElementById['test'] worked at all, to be honest.

And put in a unit with the width and height.<i>
</i>function mOver() {
var el = document.getElementById('test');
el.style.width='500px';
el.style.height='300px;
}
function mOut() {
var el = document.getElementById('test');
el.style.width='200px';
el.style.height='100px;
}
Copy linkTweet thisAlerts:
@shakeukauthorJun 08.2008 — this is my real code inc php

now it looks nothing like what i wrote b4 im sorry for being stupid and wasting ur time but do u think u could help me with this?

[code=php]
<?php
$loop = 3;
$staff_i = 0;

$query = "SELECT image, date, name, info FROM monkeyu_revtxt.events";
$result = mysql_query($query) or die('Error, insert query failed');

echo "<table>";
$i = 10;
while($value = mysql_fetch_array($result, MYSQL_ASSOC)){
$staff_i++;
$i--;

list($width, $height) = getimagesize("../../events/{$value[image]}");

echo "<tr><td><div style='z-index:{$i};position:relative;width:200px;height:100px'>
<div style='z-index:{$i};background-position;position:absolute;
background-image:url(../../events/{$value[image]});width:200px;height:100px'
onMouseOver='this.style.width=$width;this.style.height=$height'
onmouseout='this.style.width=200;this.style.height=100'></div></div></td>".
"<td><div class="text">{$value[date]}</div><div class="eventh">{$value[name]}</div>
<div class="text">{$value[info]}</div></td></tr>";
}
echo "</tr>n</table>";
?>
[/code]
Copy linkTweet thisAlerts:
@FangJun 08.2008 — 
I'm amazed that document.getElementById['test'] worked at all, to be honest.
[/QUOTE]
It's an array in IE.
Copy linkTweet thisAlerts:
@shakeukauthorJun 08.2008 — anyone know why the cose posted in php works in IE but not other browsers?

i know its a javascript issue but i dont know where im going wrong.
Copy linkTweet thisAlerts:
@shakeukauthorJun 08.2008 — ok it seems the px fixed it.

[code=php]
this.style.width=$width+"px";
[/code]
Copy linkTweet thisAlerts:
@Declan1991Jun 08.2008 — It's an array in IE.[/QUOTE]
Throwback to document.all?
×

Success!

Help @shakeuk 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.16,
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,
)...