V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
flyn

求助,无法在 wixsite.com 上使用 document.write

  •  
  •   flyn · Jun 17, 2025 · 3162 views
    This topic created in 315 days ago, the information mentioned may be changed or developed.

    我写了一个需要用到 document.write() 方法的 Bookmarklet ,但是在这个网站中无法正常使用,具体表现总是抛出错误 Uncaught TypeError: Cannot read properties of undefined (reading 'write')

    已尝试通过新建 iframe 获取干净的 write 方法并绑定到顶层 document ,依旧无效。问 AI 也没有提供可行的解决方案。

    个人水平实在是有限,求助高手帮忙看看这网站用了什么魔法阻止使用这个方法,有解决的可能吗?

    siweipancc
        1
    siweipancc  
       Jun 17, 2025 via iPhone
    append 然后 query?
    Fatinora
        2
    Fatinora  
       Jun 17, 2025
    flyn
        3
    flyn  
    OP
       Jun 17, 2025
    @siweipancc 我需要在新标签页中打开,新的页面监听 onload 事件,然后调用这些并不好使。
    @ns09005264 wixsite.com 没有配置 CSP 策略。
    SanjinGG
        4
    SanjinGG  
       Jun 18, 2025
    新标签页操作原标签页吗?这个报错很明确吧,document 没有 write 方法,一步步调吧,看 document 是什么情况
    flyn
        5
    flyn  
    OP
       Jun 18, 2025
    @SanjinGG 谢谢 已解决,网站重写了 window 对象,而我的注意力聚焦在 document
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1065 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 18:41 · PVG 02:41 · LAX 11:41 · JFK 14:41
    ♥ Do have faith in what you're doing.