滚动iPad版画面

时间:2011-10-07 17:40:25

标签: ipad iframe scroll telerik rad-controls

我正在开发一个兼容IE9 / HTML5并可在iPad上运行的Web应用程序。我遇到的问题是,当它在浏览器中正常工作时,我似乎无法在iPad上正确(或根本)滚动框架。我尝试了单指滚动和双指滚动以及下面列出的所有组合。任何帮助/想法将不胜感激。

(仅供参考:Telerik是第三方控制库)

<telerik:RadSplitter ID="radSplitter2" runat="server" Height="100%">
  <telerik:RadPane ID="RadPane2" runat="server" Scrolling="Both">
    <iframe width="100%" height="100%" scrolling="no" src="HTMLPage1.htm" />
  </telerik:RadPane>
</telerik:RadSplitter>

<telerik:RadSplitter ID="radSplitter3" runat="server" Height="100%">
  <telerik:RadPane ID="RadPane4" runat="server" Scrolling="Both" ContentUrl="HTMLPage1.htm">
  </telerik:RadPane>
</telerik:RadSplitter>

<telerik:RadSplitter ID="radSplitter4" runat="server" Height="100%">
  <telerik:RadPane ID="RadPane5" runat="server" Scrolling="Both">
    <div style="width:100%; overflow:auto">
      <iframe width="100%" height="100%" scrolling="no" src="HTMLPage1.htm" />
    </div>
  </telerik:RadPane>
</telerik:RadSplitter>

此代码有效但我真的需要能够将页面包含为框架。

<telerik:RadSplitter ID="radSplitter1" runat="server" Height="100%">
  <telerik:RadPane ID="RadPane3" runat="server" Scrolling="Both">
    This Section Scrolls
    This Section Scrolls
    This Section Scrolls
    This Section Scrolls
    This Section Scrolls
    This Section Scrolls
  </telerik:RadPane>
</telerik:RadSplitter>

3 个答案:

答案 0 :(得分:1)

对于iOS设备,您需要设置overflow: auto;或滚动不起作用。对于我的网络应用程序,我使用fancybox以模态方式显示iframe,一旦我更改了css文件中的溢出设置,两个手指滚动在iPad上完美运行。

答案 1 :(得分:0)

当指定Pane的ContentUrl属性时,您会检查内部iframe的工作原理吗?

http://demos.telerik.com/aspnet-ajax/splitter/examples/externalcontentloading/defaultcs.aspx

答案 2 :(得分:0)

解决方案最终只是强制使用javascript滚动框架:

只需将其替换为您的代码即可。

    <div id="scrollDiv" runat="server" style="position:relative; overflow:auto"></div>
    <iframe id="iFrame1" runat="server" style="display:none"></iframe>

    <script type="text/javascript" charset="utf-8">
        function initMobileScroll_<%= this.ClientID %>(ele) {
            var mobileScrollArea = document.getElementById(ele);

            mobileScrollArea.addEventListener('touchstart', function (event) {
                touchstart_<%= this.ClientID %>(event);
            });

            mobileScrollArea.addEventListener('touchmove', function (event) {
                touchmove_<%= this.ClientID %>(event);
            });

            // let’s set the starting point when someone first touches
            function touchstart_<%= this.ClientID %>(e) {
                startY = e.touches[0].pageY;
                startX = e.touches[0].pageX;
            }

            // calls repeatedly while the user’s finger is moving
            function touchmove_<%= this.ClientID %>(e) {
                var touches = e.touches[0];

                // override the touch event’s normal functionality
                e.preventDefault();

                // y-axis
                var touchMovedY = startY - touches.pageY;
                startY = touches.pageY; // reset startY for the next call
                mobileScrollArea.scrollTop = mobileScrollArea.scrollTop + touchMovedY;

                // x-axis
                var touchMovedX = startX - touches.pageX;
                startX = touches.pageX; // reset startX for the next call
                mobileScrollArea.scrollLeft = mobileScrollArea.scrollLeft + touchMovedX;
            }

        }

        var theFrame_<%= this.ClientID %> = document.getElementById('<%= iFrame1.ClientID %>');
        theFrame_<%= this.ClientID %>.onload = function () {
            var frameBody = theFrame_<%= this.ClientID %>.contentWindow.document.body.innerHTML;
            document.getElementById('<%= scrollDiv.ClientID %>').innerHTML = frameBody;
        }
        initMobileScroll_<%= this.ClientID %>('<%= scrollDiv.ClientID %>');
    </script>