Aqua-Soft Forums: Javascript problem - Aqua-Soft Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Javascript problem Rate Topic: -----

#1 User is offline   rammass18 Icon

  • Group: Member
  • Posts: 227
  • Joined: 18-June 06

Posted 22 December 2007 - 03:20 AM

hey everyone,

for the past few weeks i've been redesigning my site. i found this really cool javascript i want to use, but the problem is that the script is meant for sites that are aligned to the left. i wan to make i website aligned to the center.

here is the script:

var flash = document.getElementById('flashGallery');
flash.onmousemove = function(f){
f = f || window.event;
var x_f = getMouseX(f);
var image_f = Math.floor(x_f / 35) % 6;
setImage_f(image_f);
}
flash.onmouseout = function(f){
setImage_f(0);
}



function setImage_f(i_f){
document.getElementById('flashGallery').style.backgroundPosition = "0pt " + (-160 * i_f) + "px";
}

function getMouseX(f){
var posx_over_flash = 0;
if (f.pageX != undefined) {
posx_over_flash = f.pageX;
}
else if (f.clientX != undefined) {
posx_over_flash = f.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
}
return posx_over_flash;
}

the problem is that different browser sizes create different results. any suggestions on how to fix this
0

#2 User is offline   matonga Icon

  • Group: Developers
  • Posts: 1,286
  • Joined: 04-September 06

Posted 22 December 2007 - 04:14 AM

For the setImage_f( ) function you'll need to get the browser's window width, divide it by 2, then substract the width of your page.

A quick (and very dirty, I admit) workaround would be to put the page as an iframe, inside another page, like this:

<html>

<body>

<table border="0" width="100%">

<tr>

<td align="center" valign="top">

<iframe src="the_page.html" width="the_witdh_for_the_page" height="enough_height_to_fit_the_page"></iframe>

</td>

</tr>

</table>

</body>

</html>

0

#3 User is offline   rammass18 Icon

  • Group: Member
  • Posts: 227
  • Joined: 18-June 06

Posted 22 December 2007 - 04:22 PM

Thank You So Much!!!!!!!!!!!!!!!!
0

#4 User is offline   rick22 Icon

  • Group: Member
  • Posts: 14
  • Joined: 28-February 08

Posted 01 March 2008 - 10:49 AM

by the way... what is that script all about? please share it for newbies....
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic