I have a question. Is there is a way to override hrefs, posts and etc? In example I embed 3rd part forum inside of my container and I click anything there page response will be loaded into the same container and not reloading everything in the window.
Share
Yes, there are two ways you can do this:
Using an
iframe.iframes are independent windows embedded within the window, and so navigation within theiframestays within theiframe. So load the 3rd party forum there. This will be the easiest and most compatible way.(This is rather more complicated.) After page load, you can hook the
clickevent on links and thesubmitevent on forms with client-side Javascript. When the user clicks a link, cancel the click event and use Ajax to load the HTML for the link and then insert it into your page at the appropriate location. Similarly, when the user clicks the submit button of a form, use the event to gather the form information and send the POST via Ajax instead (cancelling the submit event), then process the response. Note that in both cases (clicking links and posting forms), the browser navigation buttons will not do what the user expects unless you also integrate a history management library into your site, which further increases complexity.