可以說我有一個這樣的網頁:使用JavaScript刪除最後一個HTML元素
<html>
<head>
<script>
//code that deletes the last element
</script>
</head>
<body>
<h1>nothing important in the body</h1>
</body>
</html>
<!-- and then there is another script element that I want to remove with javascript: -->
<script type="text/javascript" src="example.com"></script>
怎麼能使用javascript我刪除最後一個腳本元素?
只是好奇...該文件如何在文檔結束後結束? – Touffy
我決定在某天使用免費的虛擬主機,並將其加載到彈出的廣告代碼中。我沒有發現任何服務條款,說我不能嘗試刪除代碼 – Mashpoe
我懷疑它可能是這種情況。正如我在更新後的答案中所寫的,您將無法阻止腳本的執行。你必須讓它發生,然後刪除損壞(不是腳本,但它會添加到您的網頁的廢話)。 – Touffy