Hidden iFrame: do not show in history [jQuery]

I added the ajax file to my site for a long time, using a hidden iFrame. I use jQuery on my website and I have everything to work very fast. There is one problem, although I could not fix it: every time I make a new ajax request in my iFrame, the requested page is added to my browser history. I know that quite a lot of questions were asked on this topic, but I could not find a sufficient answer.

My jQuery code:

$(document).bind('ready', function() { // Add the iFrame to the DOM (iFrame is needed because of file uploads). $('body').append('<iframe id="post_form" name="post_form" style="display: none;" src="javascript:false"></iframe>'); // Show forms on click. $('a.own, a.sale, a.spotted').bind('click', function(event) { // Animate and clear the boxes. $('.box').slideFadeOut(300); $('form.' + $(this).attr('class') + ':hidden').delay(300).slideFadeIn(300)[0].reset(); return false; }); // Get the form response (from iFrame because of file uploads). $('iframe#post_form').bind('load', function() { var response = $(this).contents().find('body').html() if (response.length) { $('div#message').html(response).animate({ opacity: 'show', height: 'show', borderWidth: '1px' }, 300); } else { $('.box').slideFadeOut(300); } }); }); 

In my HTML code, I set the target attribute of my form to #post_form . I also tried to create a new iFrame for each request or manually set frame.location, but could not get it to work in conjunction with file uploads. Can anyone help?

Thanks!

+4
source share
1 answer

I believe that setting a goal does not affect history. See this post for details: Reload IFRAME without adding to history

0
source

All Articles