乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      javascript-document.write()在Firefox的用戶腳本中不起作用

       印度阿三17 2019-10-09

      我有一些使用的用戶腳本

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

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

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

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

      源代碼為空.

      該代碼可在Chrome中運行.

      我需要對較新的Firefox版本(27)和更新的Greasemonkey(1.15)進行任何修改嗎?我沒有發(fā)現(xiàn)任何有關此問題的最新錯誤報告給Firefox.

      這是一個測試腳本

      // ==UserScript==
      // @name           document.write() test
      // @namespace      
      // @description    tests document.write()
      // @include        https:///questions/22651334/*
      // @include        https:///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是否對此進行了錯誤診斷,但是從Greasemonkey腳本將window.open打開到空白頁現(xiàn)在會觸發(fā)Same Origin Policy違規(guī).
      同時,Page范圍,控制臺范圍和Firebug的控制臺都可以正常工作.

      Greasemonkey范圍提供:

      SecurityError: The operation is insecure

      是否使用@grant none.

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

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

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

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

      // ==UserScript==
      // @name        document.write () test
      // @description tests document.write ()
      // @include     https:///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);
      }
      
      來源:https://www./content-1-497701.html

        本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多