簡體   English   中英

是否可以在文檔中已經存在的注釋的內部插入第三方js腳本?

[英]Is it possible for 3rd party js scripts to be injected INSIDE of an already existing comment on the document?

我正在與其他一些開發人員討論我的同事在暫存環境中收到的一個錯誤。 基本上,他們得出的結論是:

<body>的頂部有一個<script>被注釋掉了:

<!-- <script src="some-file.js"></script>-->

並且第三方腳本被注入文檔中。 該腳本如下所示:

<!-- Begin Vendor Code -->
<script src=".."></script>
<script src=".."></script>
<!-- End Vendor Code -->

看起來已經發生了這樣的情況:在已經注釋掉了<script>標記的開始注釋之后,注入了供應商代碼:

<!--<!-- Begin Vendor Code -->
<script src=".."></script>
<script src=".."></script>
<!-- End Vendor Code --><script src="some-file.js"></script>-->

最后留下一個雜散--> ,將其顯示為實時文本。

我以前從未見過。 認為不可能嗎? 我的同事說不。 這里發生了什么?

任何幫助將不勝感激。 謝謝!

編輯:明確地說,我不是在尋找解決方案。 顯而易見的解決方案是刪除注釋掉的<script>標記。 但是我想知道這是否是真的。 我的論點是人為錯誤

XML和DOM可以訪問注釋! 不確定是否可以寫入,但可以讀取。

請參閱https://developer.mozilla.org/de/docs/Web/API/Node/nodeType,您必須遍歷Dom並檢查找到的節點類型。 “ 8”是評論!

列出頁面上所有注釋的示例代碼: http : //code.stephenmorley.org/javascript/dom-nodetype-constants/

另一個可能有用的答案: https : //stackoverflow.com/a/16151902/22470

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM