Reputation: 417
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?
Upvotes: 3
Views: 1645
Reputation: 41040
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?
Upvotes: 1
Reputation: 3502
You could simply overlay a transprent <div>
over the same area as the iframe. The iframe would load as normal but you should not be able to interact with it.
Upvotes: 1