[英]Content not appear in body
我有一個文件a.html
,其內容如下:
<script>
var x=document.URL.substring(document.URL.indexOf('#')+1);
document.write(x);
alert(document.body.innerHTML);
</script>
<body>
</body>
當我瀏覽到a.html#somevalueh;alert(1)</script>
,為什么只有"somevalueh;alert(1)"
而不是</script>
部分出現在體內?
我正在使用chrome btw。
發生這種情況是因為</script>
標記對瀏覽器具有特殊含義,並且具有開始標記,因此它會靜默刪除它。
嘗試轉義網址以獲取如下提示:
<script>
var x=document.URL.substring(document.URL.indexOf('#')+1);
document.write(escape(x));
alert(document.body.innerHTML);
</script>
<body>
</body>
這將為您提供輸出:
somevalueh%3Balert%281%29%3C/script%3E
轉義特殊字符。
更新:
您可能還想嘗試一下。 只需使用html即可,將somevalueh;alert(1)</script>
更改為somevalueh;<script>alert(1)</script>
然后檢查您的頁面,您必須在body標簽中看到<script></script>
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.