1

how to get the total/max scroll height and scroll top for an iframe content in cross browser.

i tried the bellow code which is returning scrollTop only in FireFox but i want to get scrollTop and total ScrollHeight in cross browser.

<head>
    <script src="../javascripts/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function getIframeH(){
            var scrollHeight = $('#ifrm').contents().scrollTop();
            $('#dvMsg').html("scrollHeight :: " + scrollHeight);
        }
    </script>
</head>
<body>
    <div id="dvMsg"></div>
    <input id="Button1" type="button" value="button" onclick="getIframeH();" />
    <iframe id="ifrm" src="a.xml" ></iframe>
</body>
</html>

thanks

pks
  • 101
  • 2
  • 16

1 Answers1

0

Based on this question - basically you'll need check the iframe's $("html").scrollTop(), then $("body").scrollTop() if html is 0. People have written plugins for this - don't reinvent the wheel =)

Community
  • 1
  • 1
CodeMoose
  • 2,964
  • 4
  • 31
  • 56