Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to block all request inside a <iFrame>

We need to block all requests inside a page loaded in an IFRAME tag. The page are located in the same domain, but we need to prevent the navigation in the inside page. Obviously, we don't know the elements in the inner page. They may be links (anchor link) Javascript calls, JQuery calls, Ajax calls, From submit and so on.

Here is the way we can handle simple tags and standard submit of a form:

$('a').click(function (event) {
    event.preventDefault();
    return false;
});

$(this).submit(function (event) {
    event.preventDefault();
    return false;
});

For example the first function work good but it is only an tag, but if the is triggered using JQuery that function does not work.

The second work fine only for standard form submit, but not Ajax submits.

Is there a way to handle all the events?

like image 885
User907863 Avatar asked Dec 31 '25 00:12

User907863


1 Answers

Not sure but:

$(document).click(function(event){
    event.preventDefault();
});

Or

$('*').unbind('click');
$('[href]').attr('href', '')

See this interesting answer: Best way to remove an event handler in jQuery?

like image 56
powtac Avatar answered Jan 02 '26 12:01

powtac