免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
javascript-document.write()在Firefox的用戶腳本中不起作用

我有一些使用的用戶腳本

var tab = window.open('', '_blank');tab.document.write(myCustomHtml);tab.document.close();

向用戶顯示輸出(myCustomHtml是我之前在代碼中定義的一些有效HTML).自版本27起,它在Firefox中停止工作,現(xiàn)在我只得到一個(gè)空文檔.沒(méi)有任何控制臺(tái)錯(cuò)誤.

使用Firefox的控制臺(tái)檢查時(shí),新打開(kāi)的文檔僅具有此內(nèi)容

<html>    <head></head>    <body>    </body></html>

源代碼為空.

該代碼可在Chrome中運(yùn)行.

我需要對(duì)較新的Firefox版本(27)和更新的Greasemonkey(1.15)進(jìn)行任何修改嗎?我沒(méi)有發(fā)現(xiàn)任何有關(guān)此問(wèn)題的最新錯(cuò)誤報(bào)告給Firefox.

這是一個(gè)測(cè)試腳本

// ==UserScript==// @name           document.write() test// @namespace      stackoverflow.com// @description    tests document.write()// @include        https://stackoverflow.com/questions/22651334/*// @include        https://stackoverflow.com/questions/22651334/*// @version        0.0.1// ==/UserScript==var tab = window.open('', '_blank');tab.document.write('<html><head></head><body><ul><li>a</li><li>b</li><li>c</li></ul></body></html>');tab.document.close();

解決方法:

我不確定Greasemonkey或Firefox是否對(duì)此進(jìn)行了錯(cuò)誤診斷,但是從Greasemonkey腳本將window.open打開(kāi)到空白頁(yè)現(xiàn)在會(huì)觸發(fā)Same Origin Policy違規(guī).
同時(shí),Page范圍,控制臺(tái)范圍和Firebug的控制臺(tái)都可以正常工作.

Greasemonkey范圍提供:

SecurityError: The operation is insecure

是否使用@grant none.

加上普遍的無(wú)用GM_openInTab(),使我懷疑這是Greasemonkey的錯(cuò)誤.我現(xiàn)在沒(méi)有時(shí)間研究它,但是如果您愿意,可以查看file a bug report.

要使其在最新版本的Firefox(28.0)和Greasemonkey(1.15)上起作用,這是我必須要做的:

>告訴我的彈出窗口阻止程序(臨時(shí))允許來(lái)自stackoverflow.com的彈出窗口.
>將彈出代碼插入頁(yè)面范圍.
>使用明確的about:blank作為網(wǎng)址.
>等待新窗口加載.

這是適用于最新FF GM版本的完整腳本:

// ==UserScript==// @name        document.write () test// @description tests document.write ()// @include     https://stackoverflow.com/questions/22651334/*// ==/UserScript==function fireNewTab () {    var newTab = window.open ('about:blank', '_blank');    newTab.addEventListener (        "load",        function () {            //--- Now process the popup/tab, as desired.            var destDoc = newTab.document;            destDoc.open ();            destDoc.write ('<html><head></head><body><ul><li>a</li><li>b</li><li>c</li></ul></body></html>');            destDoc.close ();        },        false    );}addJS_Node (null, null, fireNewTab);function addJS_Node (text, s_URL, funcToRun, runOnLoad) {    var D                                   = document;    var scriptNode                          = D.createElement ('script');    if (runOnLoad) {        scriptNode.addEventListener ("load", runOnLoad, false);    }    scriptNode.type                         = "text/javascript";    if (text)       scriptNode.textContent  = text;    if (s_URL)      scriptNode.src          = s_URL;    if (funcToRun)  scriptNode.textContent  = '('   funcToRun.toString()   ')()';    var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;    targ.appendChild (scriptNode);}
來(lái)源:https://www.icode9.com/content-1-497701.html
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
?。?!UserScript(用戶腳本)在Firefox、Google Chrome、Opera、IE6
火狐———Stylish樣式列表
JavaScript動(dòng)態(tài)加載script方式引用百度地圖API,Uncaught ReferenceError: BMap is not defined
如何在firefox瀏覽器里面得到選中的文本
100個(gè)直接可以拿來(lái)用的JavaScript實(shí)用功能代碼片段
JavaScript常用的代碼片段 | Poetry''''s Blog
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服