iPad 的滚动框架

发布于 2024-12-08 20:28:17 字数 1549 浏览 0 评论 0原文

我正在开发一个 Web 应用程序,该应用程序将兼容 IE9/HTML5 并在 iPad 上运行。我遇到的问题是,当它在浏览器中正常工作时,我似乎无法让框架在 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>

I am developing a web application that is going to be both IE9/HTML5 compatible and work on the iPad. The issue I'm running into is that I can't seem to get frames to scroll correctly (or at all) on the iPad while it works fine in a browser. I have tried both single finger scrolling and two-finger scrolling and all of the listed combinations below. Any help/ideas would be greatly appreciated.

(FYI: Telerik is a third party control library)

<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>

This code works but I really need to be able to include a page as a frame.

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

毅然前行 2024-12-15 20:28:18

当指定 Pane 的 ContentUrl 属性时,您会检查它如何与内部 iframe 一起工作吗?

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

Would you check how it works with internal iframe(s) when Pane’s ContentUrl property is specified?

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

错爱 2024-12-15 20:28:18

解决方案最终只是使用 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>

The solution ended up being just forcing the frames to scroll using javascript:

just put this in place of your tag.

    <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>
若相惜即相离 2024-12-15 20:28:17

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

For iOS devices you need set overflow: auto; or the scrolling won't work. For my web apps I used fancybox to display iframes modally and once I change the overflow setting in the css file the two finger scroll worked perfectly on the iPad.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文