MozillaZine


problem with script

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

Post Posted March 5th, 2015, 1:15 pm

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 !

DanRaisch
Moderator

User avatar
 
Posts: 124075
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted March 5th, 2015, 2:24 pm

Moving to Web Development.

trolly
Moderator

User avatar
 
Posts: 39909
Joined: August 22nd, 2005, 7:25 am

Post Posted March 5th, 2015, 3:48 pm

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.

patrickjdempsey

User avatar
 
Posts: 23734
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC

Post Posted March 5th, 2015, 4:17 pm

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

Post Posted March 6th, 2015, 3:56 pm

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 !

patrickjdempsey

User avatar
 
Posts: 23734
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC

Post Posted March 7th, 2015, 12:44 am

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

Post Posted March 7th, 2015, 2:20 pm

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 .

patrickjdempsey

User avatar
 
Posts: 23734
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC

Post Posted March 7th, 2015, 3:08 pm

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/

Return to Web Development / Standards Evangelism


Who is online

Users browsing this forum: Bing [Bot] and 2 guests