2
我的代碼檢查他們在這裏: -選擇所有的I幀,並用JavaScript
<iframe src="http://www.website.com/abc.ext" width="600px" height="400px"></iframe><br />
<iframe src="http://www.anotherwebsite.com/link.py" width="600px" height="400px"></iframe>
現在,我要選擇用JavaScript兩I幀,並檢查他們的SRC。我想只允許iframe的www.website.com。我想創建一個JavaScript代碼,只顯示包含www.website.com的iframe,其他人將被隱藏。
請讓我知道這有可能嗎?
爲什麼不刪除 「代碼」 的其他I幀? – Aprillion
使用'document.getElementsByTagName(「iframe」)',然後遍歷該集合,獲取每個'src'屬性,然後檢查其中的字符串:if(item.src.indexOf(「http:// www。 website.com「)=== 0)'。 – Ian