全栈开发技术分享
首页
👉 CSS大揭秘 👈
  • 目录
  • 分类
  • 标签
  • 归档
  • Vue
  • JavaScript
  • 微信开发
  • 移动端H5调试工具
  • 国内十大前端团队网站
  • Nodejs
  • Egg
  • 环境搭建
  • 运维面板
  • 域名配置
  • Nginx
  • 收藏
  • 常用工具
  • 实用技巧
  • 常用命令
  • 友情链接
关于

Dreaming Lee 🍍 ҉҉҉҉҉҉҉҉

开发小菜鸡
首页
👉 CSS大揭秘 👈
  • 目录
  • 分类
  • 标签
  • 归档
  • Vue
  • JavaScript
  • 微信开发
  • 移动端H5调试工具
  • 国内十大前端团队网站
  • Nodejs
  • Egg
  • 环境搭建
  • 运维面板
  • 域名配置
  • Nginx
  • 收藏
  • 常用工具
  • 实用技巧
  • 常用命令
  • 友情链接
关于
  • 代码规范

    • Eslint
    • Eslint-Plugin-Vue
    • Stylelint
  • uniapp

    • 问题解决

      • 【uniapp】字节小程序BUG - “navigateToMiniProgram/getUserProfile:fail must be invoked by user tap gesture”
  • JavaScript

    • JS验证18位身份证号码
    • JS图片压缩
    • JS调用elementUI图片预览
    • JS图片上传前校验大小、尺寸
  • Vue

    • Vue基础教程

      • Vue教程(1)-基础篇
      • Vue教程(2)-路由篇Vue-Router
      • Vue教程(3)- 状态管理Vuex
    • Vue自定义组件开发

      • Vue实现移动端轮播swiper组件
      • Vue实现switch开关组件
    • Vue扩展

      • Vue接入阿里OSS文件上传
    • Vue学习参考资料
  • 微信开发

    • 微信开发参考资料
    • 微信公众号

      • 微信公众号/订阅号/服务号主动给用户发消息
      • 微信jssdk自定义分享在iOS不生效
    • 微信小程序

      • 微信小程序区分运行环境:开发版/体验版/正式版
      • H5唤醒微信小程序
  • 收藏

    • 国内十大前端团队官网及GitHub
  • 常见问题解决

    • js错误

      • iframe下localStorage禁止访问。“Failed to read the localStorage property from Window”
        • TypeError: Promise.allSettled is not a function
      • IE兼容

        • fixed定位在IE下页面滚动时抖动
    • 工具

      • 移动端H5调试工具
    • 前端
    • 常见问题解决
    • js错误
    Dreaming Lee 🍍 ҉҉҉҉҉҉҉҉
    2022-08-29

    iframe下localStorage禁止访问。“Failed to read the localStorage property from Window”

    # 问题原因

    • 浏览器开启“阻止第三方Cookie”
    • iframe内嵌页面使用 localStorage 则会出现js报错,导致页面无法正常展示
    Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
    
    1

    # 解决方案

    try {
      window._localStorage = window.localStorage
    } catch() {
      window._localStorage = {
        getItem: function(key) { return '' },
        setItem: function(key, value) {},
        removeItem: function(key) {},
        clear: function() {},
      }
    }
    
    // 使用
    _localStorage.getItem('key')
    _localStorage.setItem('key', 'value')
    _localStorage.removeItem('key')
    _localStorage.clear()
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    上次更新: 2022-08-30 09:53:40
    国内十大前端团队官网及GitHub
    TypeError: Promise.allSettled is not a function

    ← 国内十大前端团队官网及GitHub TypeError: Promise.allSettled is not a function→

    最近更新
    01
    【uniapp】字节小程序BUG - “navigateToMiniProgram/getUserProfile:fail must be invoked by user tap gesture”
    06-21
    02
    七牛云上传自有证书
    04-27
    03
    使用腾讯云申请免费SSL证书
    04-27
    更多文章>
    Theme by Vdoing | Copyright © 2020-2024 | 豫ICP备2020030395号 | 靳立祥 | MIT License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式