document.body.scroll does not work in Firefox

S

sam

Hi all,

I am using documnet.body.scroll to disable the window scroll bar. This
works in IE only and not other browsers.

Can any one tell me if there is any such method which is cross browser
compatible.

Thanks,
sam
 
R

Randy Webb

sam said the following on 6/5/2006 6:11 PM:
Hi all,

I am using documnet.body.scroll to disable the window scroll bar.

Really? Why are you trying to do something so anti-user friendly?
This works in IE only and not other browsers.

That's generally the way IE only code works.
Can any one tell me if there is any such method which is cross browser
compatible.

To do what? Stop a user from scrolling a page? overflow:hidden
 
S

sam

Thats our product design, I have no choice to change the app design. To
be more clear.
I am trying to disable the browser scroll bar when ever a popup shows
up so that only popup is accessible. I tried using overflow: hidden
but it does not do what is required.
The problem with overflow: hidden.
1) I have alenghty page, I scroll half way down and open a popup and my
popup is centered in the viewport, and now I should be able to disable
the scroll there so that the content in main window is visible but not
accessbile.

when i use overflow: hidden it always jumps to the top and picks that
area and disappears the scroll bar, in which process i cannot see my
popup which is struck far below and also the content which I was
supposed.
I hope I am not too confusing.


Thanks
sam
 
R

Randy Webb

sam said the following on 6/5/2006 7:19 PM:
Thats our product design, I have no choice to change the app design. To
be more clear.

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

Please don't top-post :)
I am trying to disable the browser scroll bar when ever a popup shows
up so that only popup is accessible. I tried using overflow: hidden
but it does not do what is required.

Ahh, now I think I understand. You are using an in-window dHTML pop-up
rather than the typical pop-up caused by window.open
The problem with overflow: hidden.
1) I have alenghty page, I scroll half way down and open a popup and my
popup is centered in the viewport, and now I should be able to disable
the scroll there so that the content in main window is visible but not
accessbile.

Find the top and left of your popup, use the window.onscroll to know
when the document gets scrolled, then use window.scrollTo to scroll back
to where you started.

You have to set a flag when the popup is displayed. When the window gets
scrolled, you check that flag. If a popup is showing, you don't allow
the scroll. If it is not showing, then you allow the scrolling.


var stopScroll = false;
var popupTop = 0;
window.onscroll = stopScrolling

function stopScrolling(){
if (stopScroll){
window.scrollTo(0,popupTop)
}
}

function showPopup(){
stopScroll = true;
popupTop = XXX
//XXX would be the top position of the
//popup window.

//rest of popup code here
}

function hidePopup(){
stopScroll = false;
//code here to hide the popup
}

That is a start, it will take more than that to do what you need to do
but it's a start.
 
T

The Magpie

sam said:
I am using documnet.body.scroll to disable the window scroll bar. This
works in IE only and not other browsers.

Can any one tell me if there is any such method which is cross browser
compatible.
Sam,

What you are doing is assuming the scroll bar belongs not only to the
particular document you display but also to the body part of that
document. However, given that any application *window* can choose to
display a scroll bar, it should be obvious that the thing you want to
really do is disable the feature in a window, not a document.

Yes, it is true that a document will set up a scroll bar in the window
(or within the web page for a <div> layer), but you appear to want to
disable the *window* feature - which is part of the underlying GUI of
the application. Naturally, the application can - and in many cases may
well - simply refuse to let you.

In this case though, a trip to www.w3c.org might help you find the
standard way to look at what you want to achieve. From your follow-ups,
it seems that you actually want to style a pop-up and that is certainly
possible. Remember though that many browsers may simply refuse to let
you have a pop-up, much less to style it in such an unfriendly way.
 
S

Stephen Chalmers

sam said:
Hi all,

I am using documnet.body.scroll to disable the window scroll bar. This
works in IE only and not other browsers.

Can any one tell me if there is any such method which is cross browser
compatible.
If you don't find a better way, this may have to be a job for ScrollFreeze.

Usage: ScrollFreeze.on() , ScrollFreeze.off()

<SCRIPT type='text/javascript'>

ScrollFreeze = /*2843293230303620532E4368616C6D657273*/
{
propFlag : true,
Ydisp : 0,
Xdisp : 0,

on : function()
{
if(this.getProp())
window.onscroll=function(){ ScrollFreeze.setXY(); }
},

off : function(){window.onscroll=null;},

getProp : function()
{
if( typeof window.pageYOffset != 'undefined' )
{
this.Ydisp=window.pageYOffset;
this.Xdisp=window.pageXOffset;
}
else
if(document.documentElement)
{
this.Ydisp=document.documentElement.scrollTop;
this.Xdisp=document.documentElement.scrollLeft;
}
else
if(document.body && typeof document.body.scrollTop != 'undefined')
{
this.Ydisp=document.body.scrollTop;
this.Xdisp=document.body.scrollLeft;
}
else
this.propFlag=false;

return this.propFlag;
},

setXY : function()
{
window.scrollTo( this.Xdisp, this.Ydisp );
}
}

</SCRIPT>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top