-
Floating problem
Hi again,
I have a great little script to float a navigation section for long
pages and it works perfectly in all browsers except IE.
Here's the script:
<script type="text/javascript" language="JavaScript">
function FloatPosition()
{
var ns = (navigator.appName.indexOf('Netscape') != -1);
var pos = document.getElementById('NavBar');
var pad = ns ? pageYOffset : document.body.scrollTop;
if(pad < 1) { pad = 0; }
pos.style.height = pad + 'px';
}
onscroll=FloatPosition;
onresize=FloatPosition;
</script>
And of course you ad the 'NavBar' div to the element.
So, can this be made to work in IE (seems IE has a problem with
getElementById) or is there a better method all together?
Paul
-
Re: Floating problem
On 23/02/2010 18:21, Adendum wrote:
> Hi again,
>
> I have a great little script to float a navigation section for long
> pages and it works perfectly in all browsers except IE.
>
> Here's the script:
>
> <script type="text/javascript" language="JavaScript">
> function FloatPosition()
> {
> var ns = (navigator.appName.indexOf('Netscape') != -1);
> var pos = document.getElementById('NavBar');
> var pad = ns ? pageYOffset : document.body.scrollTop;
> if(pad < 1) { pad = 0; }
> pos.style.height = pad + 'px';
> }
> onscroll=FloatPosition;
> onresize=FloatPosition;
> </script>
>
> And of course you ad the 'NavBar' div to the element.
>
>
> So, can this be made to work in IE (seems IE has a problem with
> getElementById) or is there a better method all together?
>
> Paul
It's not the getElementById that's the problem, it's a combination of
document.body.scrollTop and the DOCTYPE. Seems various flavours of IE
have issues with this, especially in Quirks mode (unfortunately NOF's
DOCTYPE is - technically - incomplete and seems to trip this)
A suggested IE6 workaround is to use
'document.documentElement.scrollTop' instead of
'document.body.scrollTop'. Seems to have an effect, but not quite the
same in IE as FF :-(
In the ideal (CSS 2.1) world you could use 'position:fixed' in the CSS
properties (with top and left set as required). This positions an
element - e.g. the NavBar div - with respect to the browser window, not
the page. Works a treat in FF et al, but quite so cleanly in IE (6 not
at all, 7/8 only if you have <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.0 Transitional//EN">). Sigh.
HTH,
Derek
-
Re: Floating problem
Derek,
Thanks for that. There's another alternative too - which I opted for -
AllWebMenus! Not the cheapest route but it has a load of other benefits.
Paul
On 25/02/2010 21:26, Derek wrote:
> On 23/02/2010 18:21, Adendum wrote:
>> Hi again,
>>
>> I have a great little script to float a navigation section for long
>> pages and it works perfectly in all browsers except IE.
>>
>> Here's the script:
>>
>> <script type="text/javascript" language="JavaScript">
>> function FloatPosition()
>> {
>> var ns = (navigator.appName.indexOf('Netscape') != -1);
>> var pos = document.getElementById('NavBar');
>> var pad = ns ? pageYOffset : document.body.scrollTop;
>> if(pad < 1) { pad = 0; }
>> pos.style.height = pad + 'px';
>> }
>> onscroll=FloatPosition;
>> onresize=FloatPosition;
>> </script>
>>
>> And of course you ad the 'NavBar' div to the element.
>>
>>
>> So, can this be made to work in IE (seems IE has a problem with
>> getElementById) or is there a better method all together?
>>
>> Paul
>
> It's not the getElementById that's the problem, it's a combination of
> document.body.scrollTop and the DOCTYPE. Seems various flavours of IE
> have issues with this, especially in Quirks mode (unfortunately NOF's
> DOCTYPE is - technically - incomplete and seems to trip this)
>
> A suggested IE6 workaround is to use
> 'document.documentElement.scrollTop' instead of
> 'document.body.scrollTop'. Seems to have an effect, but not quite the
> same in IE as FF :-(
>
> In the ideal (CSS 2.1) world you could use 'position:fixed' in the CSS
> properties (with top and left set as required). This positions an
> element - e.g. the NavBar div - with respect to the browser window,
> not the page. Works a treat in FF et al, but quite so cleanly in IE (6
> not at all, 7/8 only if you have <!DOCTYPE html PUBLIC "-//W3C//DTD
> XHTML 1.0 Transitional//EN">). Sigh.
>
> HTH,
>
> Derek
-
Re: Floating problem
On 25/02/2010 21:33, Adendum wrote:
> Derek,
>
> Thanks for that. There's another alternative too - which I opted for -
> AllWebMenus! Not the cheapest route but it has a load of other benefits.
>
:-)
Yeah, wrap an SEP field around it (Somebody Else's Problem, for those
that don't know!) AWM is a nice product...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules