首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

在iOS 10测试版上,window.outerWidth在Safari中为0

的原因是因为Safari浏览器在iOS 10测试版中对于window.outerWidth属性的实现存在问题。window.outerWidth属性用于获取浏览器窗口的外部宽度,但在该测试版中,Safari浏览器返回的值为0,这可能是一个bug。

由于window.outerWidth属性在Safari中无法正常工作,开发人员需要考虑使用其他方法来获取浏览器窗口的宽度。一种可行的替代方法是使用document.documentElement.clientWidth属性来获取浏览器窗口的宽度。

以下是对于window.outerWidth属性在Safari中为0的解决方案:

  1. 使用document.documentElement.clientWidth属性来获取浏览器窗口的宽度。该属性返回文档元素的可见宽度,即浏览器窗口的宽度,不包括滚动条和边框的宽度。
  2. 可以通过JavaScript代码来获取浏览器窗口的宽度,示例代码如下:
代码语言:txt
复制
var windowWidth = window.innerWidth || document.documentElement.clientWidth;

上述代码首先尝试使用window.innerWidth属性获取浏览器窗口的宽度,如果该属性不可用,则使用document.documentElement.clientWidth属性作为备选方案。

在实际开发中,如果需要根据浏览器窗口的宽度来进行响应式布局或其他相关操作,建议使用上述替代方法来获取浏览器窗口的宽度。

腾讯云相关产品和产品介绍链接地址:

  • 腾讯云移动开发平台:https://cloud.tencent.com/product/mpp
  • 腾讯云云服务器(CVM):https://cloud.tencent.com/product/cvm
  • 腾讯云数据库(TencentDB):https://cloud.tencent.com/product/cdb
  • 腾讯云人工智能(AI):https://cloud.tencent.com/product/ai
  • 腾讯云物联网(IoT):https://cloud.tencent.com/product/iotexplorer
  • 腾讯云存储(COS):https://cloud.tencent.com/product/cos
  • 腾讯云区块链(BCS):https://cloud.tencent.com/product/bcs
  • 腾讯云元宇宙(Metaverse):https://cloud.tencent.com/product/metaverse

请注意,以上链接仅供参考,具体的产品选择应根据实际需求和情况进行评估和决策。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

  • Planetary.js 旋转地球插件

    (function() { var canvas = document.getElementById('quakeCanvas'); // Create our Planetary.js planet and set some initial values; // we use several custom plugins, defined at the bottom of the file var planet = planetaryjs.planet(); planet.loadPlugin(autocenter({extraHeight: -120})); planet.loadPlugin(autoscale({extraHeight: -120})); planet.loadPlugin(planetaryjs.plugins.earth({ topojson: { file: 'https://101.43.39.125/HexoFiles/js/planetaryjs/world-110m.json' }, oceans: { fill: '#001320' }, land: { fill: '#06304e' }, borders: { stroke: '#001320' } })); planet.loadPlugin(planetaryjs.plugins.pings()); planet.loadPlugin(planetaryjs.plugins.zoom({ scaleExtent: [50, 5000] })); planet.loadPlugin(planetaryjs.plugins.drag({ onDragStart: function() { this.plugins.autorotate.pause(); }, onDragEnd: function() { this.plugins.autorotate.resume(); } })); planet.loadPlugin(autorotate(5)); planet.projection.rotate([100, -10, 0]); planet.draw(canvas); // Plugin to resize the canvas to fill the window and to // automatically center the planet when the window size changes function autocenter(options) { options = options || {}; var needsCentering = false; var globe = null; var resize = function() { var width = window.outerWidth /2 + (options.extraWidth || 0); var height = window.outerHeight/2 + (options.extraHeight || 0); globe.canvas.width = width; globe.canvas.height = height; globe.projection.translate([width / 2, height / 2]); }; return function(planet) { globe = planet; planet.onInit(function() { needsCentering = true; d3.select(window).on('resize', function() { needsCentering = true; }); }); planet.onDraw(function() { if (needsCentering) { resize(); needsCentering = false; } }); }; }; // Plugin to automatically scale the planet's projection based // on the window size when the planet is initia

    03

    阻止iOS Web APP中点击链接跳转到Safari 浏览器新标签页

    iOS 上的Safari 浏览器中有一个“发送到屏幕”的功能(虽然很多小白用户都不知道这个),用户是可以把网站的URL以一个快捷方式的形式添加到主屏幕的,展示形式跟原生的应用是一样并最大限度地模拟本地APP 的效果(当然,需要开发者本身做一些代码层面的设置,见《将你的网站打造成一个iOS Web App》、《iOS / Android 移动设备中的 Touch Icons》这两篇文章)。此所谓 Web APP 是也。 DeveMobile 与EaseMobile 主题 也有这个功能。不过,现在发现了个问题,就是通过主屏幕上点击进入Web APP 形式的网页时候,点击任何一个链接就会跳转到Safari 浏览器并新建一标签页打开所属链接——这个功能真心恶心,如果这样的话还是Web APP吗?真不知苹果怎么想的,人家安卓的也不会这样啊。

    03
    领券