problem with script

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Post Reply
zaiko2000
Posts: 20
Joined: March 22nd, 2010, 4:22 pm

problem with script

Post by zaiko2000 »

I made a website and it works in every browser but only firefox gives me a problem.
I made a responsive design website which works fine but for an adobe edge animated slideshow I had to add a script for the smartphone design .
After the slideshow i got a big white space. To get rid of it i had to insert this script :
<script>
function fixHeight() {
var anim = document.getElementById('EdgeID'),
w = anim.offsetWidth;
anim.style.height = (w * .562) + 'px';
}
fixHeight();
window.addEventListener('resize', fixHeight, false);
</script>

Now this works perfect for every browser only for firefox not : in firefox the slideshow doesn't show anymore !
You can look for yourself : http://www.delounge.eu

anybody has an idea ? i don't know enough about scripts to solve the problem .

I almost forgot when I use webdeveloper in firefox it shows !
User avatar
DanRaisch
Moderator
Posts: 127233
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Re: problem with script

Post by DanRaisch »

Moving to Web Development.
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: problem with script

Post by trolly »

Code: Select all

<object style="height: 0px;" id="EdgeID" type="text/html" data-dw-widget="Edge" data="edgeanimate_assets/slideshow/Assets/slideshow.html" width="920" height="420">
</object>

The height is calculated to zero.

If I resize the window the slideshow appears. Most likely the function is called before the width of the container can be calculated. You should use a timer to call that function.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
User avatar
patrickjdempsey
Posts: 23686
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC
Contact:

Re: problem with script

Post by patrickjdempsey »

Or use an onload event to make sure the script isn't called before that element is created.

https://developer.mozilla.org/en-US/doc ... ers/onload
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/
zaiko2000
Posts: 20
Joined: March 22nd, 2010, 4:22 pm

Re: problem with script

Post by zaiko2000 »

yes but why does that only happens in firefox ?
All the other berowsers are ok !

And I used this script from a tutorial , I don't understand anything from javascript !
User avatar
patrickjdempsey
Posts: 23686
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC
Contact:

Re: problem with script

Post by patrickjdempsey »

Unless that tutorial was from 1996, I don't think I've ever seen it recommended to run scripts that depend on drawn elements as soon as possible. Onload event on the window is and has been standard for a good decade.
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/
zaiko2000
Posts: 20
Joined: March 22nd, 2010, 4:22 pm

Re: problem with script

Post by zaiko2000 »

that tutorial was from 2014 and it works in every browser ! except in firefox .
The purpose is to reduce the white space after the adobe edge animation on a smartphone .
User avatar
patrickjdempsey
Posts: 23686
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC
Contact:

Re: problem with script

Post by patrickjdempsey »

Well that says a lot. A bunch of the "responsive web design" stuff out there is only tested in Webkit (Safari, Chrome). You should never run scripts that look for elements on the page directly like that.
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/
Post Reply