protld protld - 1 year ago 67
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.


Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download