html - 对象/iframe 溢出滚动在 ios (cordova) 中不起作用

标签 html ios css cordova

我正在使用 cordova 8.1.2 在 iframe/object 中加载我的页面。但滚动在 iPhone 中不起作用。

下面cordova中的config.xml内容

<content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <allow-navigation href="*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="*" />
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <preference name="android-targetSdkVersion" value="26" />
    <preference name="loadUrlTimeoutValue" value="700000" />
    <engine name="android" spec="^7.1.2" />
    <engine name="ios" spec="^4.5.5" />

用于 iframe 的代码:

    <html lang="en" class="no-js">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self'">
      <meta name="viewport" content="user-scalable=no, initial-scale=1, minimum-scale=1, width=device-width" />    
   </head>
   <body style="overflow:hidden; height:100%;">
      <div style="overflow:scroll !important; -webkit-overflow-scrolling:touch !important;">
      <iframe id="frame-one" data-tap-disabled="true" frameborder="0" src="my-url-website"></iframe>
      </div>
   </body>
</html>

用于对象标签的代码:

   <body style="overflow:hidden; height:100%;">
      <div style="overflow:scroll !important; -webkit-overflow-scrolling:touch !important;">
         <object id="previllew-frame" style="width:100%;height:100%" data="my-url-website"></object>
      </div>
   </body>

请帮帮我,谢谢。

最佳答案

我在 iOS 上为我正在处理的网络相关元素遇到了同样的问题。所以我很确定问题与 Safari/Webkit 相关。我还没有找到解决方案,但问题似乎与 Cordova 无关。尝试看看您是否可以弄清楚如何让您的代码在 Safari 中作为网页工作。

编辑:

好的,所以我找到的答案是,如果您为 iframe 设置 scrolling=no,那么错误就会消失。不幸的是,我正在处理的元素需要有一个滚动的 iframe,所以这对我来说是个问题,但我希望这个解决方案能有所帮助!

var iFrame = document.getElementById("iFrame");
iFrame.scrolling = "no";

关于html - 对象/iframe 溢出滚动在 ios (cordova) 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54380016/

相关文章:

jquery - 我的响应式菜单在移动设备上不起作用

javascript - 在每个循环中单击一个元素时如何删除所有同级元素的类

javascript - div 元素不使用 javascript 更新

jquery - 固定位置模态滚动/焦点

javascript - 如何使用外部 div 元素的 Onclick 事件

asp.net - asp :label and HTML label?有什么区别

html - iOS 浏览器 : use actual browser size (independent of eventual toolbar) for CSS styling

iphone - XCOde 4 如何在 xib 中旋转 View ?

css - 我如何根据文本拉伸(stretch)我的div?

php - IOS 应用程序、搜索框和 SQL 数据库