SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Dec 10, 2006, 16:14 #1
- Join Date
- Oct 2004
- Location
- Newport Beach
- Posts
- 1,761
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Javascript IFrame Height Change Not Working if FF
The script below works perfect at changing the height of an iframe depending on a dynamic factor.
Code:<script language="javascript"> if (document.all) { window.document.all.slideshow.style.height = 88; } else { i = window.document.getElementById("slideshow"); i.style.height = 88; } </script>
Thanks
Ryan
-
Dec 10, 2006, 16:46 #2
- Join Date
- Jul 2006
- Posts
- 151
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well first off, document.all is pretty much unnecessary now-a-days with the modern browsers, unless you are trying to make sure that IE 4 recognizes your script (and I think Iframes fail in IE4 anyway) so you are probably fine to scrap the use of the conditional.
2nd, when using Javascript to set style attributes, you have to treat the attributes as strings, even if they are numbers. So hence:
Code:i.style.height = "88px";
-
Dec 10, 2006, 18:48 #3
- Join Date
- Sep 2006
- Posts
- 731
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Dec 10, 2006, 21:50 #4
- Join Date
- Oct 2004
- Location
- Newport Beach
- Posts
- 1,761
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
using the px and the quotes got it working.
Thanks
Ryan
-
Dec 11, 2006, 03:46 #5
- Join Date
- Sep 2006
- Posts
- 731
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Dec 11, 2006, 08:02 #6
- Join Date
- Mar 2005
- Location
- USA
- Posts
- 5,482
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Why are you using document.all? IE5+ support document.getElementById().
What happens if an Netscape 4 user tries to use that?
My suggestion is that if you want to support IE4, you can use the following and just test for document.getElementById() support.
Code:if(document.all && !document.getElementById) { //IE4 support document.getElementById = function(id) { return document.all[id]; } }
We miss you, Dan Schulz.
Learn CSS. | X/HTML Validator | CSS validator
Dynamic Site Solutions
Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.
Bookmarks