Alex Rivera | Logout

How can I detect a Scrollbar presence ( using Javascript ) in HTML iFrame?

Asked 2009-03-25T10:59:30.600
25

How can I detect a Scrollbar presence ( using Javascript ) in HTML iFrame ?

I have already tried :

        var vHeight = 0;
        if (document.all) {
          if (document.documentElement) {
            vHeight = document.documentElement.clientHeight;
          } else {
            vHeight = document.body.clientHeight
          }
    } else {
      vHeight = window.innerHeight;
    }

    if (document.body.offsetHeight > vHeight) {
      //when theres a scrollbar
    }else{
      //when theres not a scrollbar
    }

And I also had tried :

           this.scrollLeft=1;
    if (this.scrollLeft>0) {
        //when theres a scrollbar
        this.scrollLeft=0;
        }else{
        //when theres not a scrollbar
        return false;
    }

With no success..

I have searched the javascript objets on DOM Inspector, but didn't find anything.

Is is possible to detect a scrollbar presence in a iframe in javacscript ?


The iframe content comes from the same domain.

No success until now..

alt text http://www.upvtp.com.br/file.php/1/help_key.jpg

Edit
Report

1 Answer

1

I do not think this can be done if the iframe content comes from another domain due to JavaScript security limitations.

EDIT: In that case, something along the lines of giving the iframe a name='someframe' and id='someframe2' and then comparing frames['someframe'].document.body.offsetWidth with document.getElementById('someframe2').offsetWidth should give you the answer.

answered 2009-03-25T11:24:31.960

Your Answer