protld protld - 1 month ago 6x
HTML Question

Redirect to page if iFrame url is

I want to use javascript, so if an iframe on my page's url became '' it must do a function

Function for example:

  • Redirect to error.php using "window.href"

  • Show javascript box saying "error"

My iframe is:

<iframe src="" id="myframe"></iframe>

And I want to prevent my site visitors to go to the Google homepage.



If you are using jquery $(document).ready(function (){ var a = $('#myiframe').attr('src'); If(a == '' || a=='' || a=='’){ window.location.href="error.php"; } });