![](/img/trans.png)
[英]how to set all links in iframe to “google.com” by javascript or jQuery?
[英]Redirect to page if iFrame url is google.com
我想使用javascript,因此,如果頁面網址上的iframe變為“ https://google.com.eg ”,則它必須具有功能
功能例如:
我的iframe是:
<iframe src="https://translate.google.com.eg" id="myframe"></iframe>
而且,我想阻止我的網站訪問者訪問Google主頁。
謝謝!
在iframe加載函數中,檢查document.getElementById(“ myiframe”)。contentWindow.location.href ==“ google.com”,然后繼續執行回調
如果您使用的是jQuery $(document).ready(function(){ var a = $('#myiframe').attr('src');
If(a =='www.google.com'|| a = ='google.com'|| a ==' https: //google.com.eg'){window.location.href =“ error.php”;}}));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.