Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
111
rated 0 times [  118] [ 7]  / answers: 1 / hits: 27589  / 15 Years ago, thu, february 11, 2010, 12:00:00

I have a page with dynamic data loaded by some ajax and lots of javascript.



the page contains a list from which the user can choose and each selected value loads new data to the page.



One of these data items is a url provided to an iframe.



I use jQuery BBQ: Back Button & Query Library to simulate the browser-back behavior.



All works well besides the fact that when i click the back button for the first time the iframe goes back to its previous location and then I need to click back again to make the page go back.



Is there a way to disable the iframe's back behavior?


More From » html

 Answers
38

I've found the answer to my problem guess it could be useful for others out there.



The problem was with the way i assigned new URLs to my Iframe, i used Jquery so it looked something like that:



$('#myIFrame').attr('src',newUrl);


When assigning the URL in that manner it adds a new entry to the browser's list of visited URLs to go back to.

That wasn't the desired behavior, so after some googling i found that you can assign a new URL to an Iframe object without adding it to the 'back-list', it looks like that:



var frame = $('#myIFrame')[0];  
frame.contentWindow.location.replace(newUrl);


This way my back button behave exactly as expected.



btw, i got my answer from here.



Hope this was helpful to you as it was to me.


[#97601] Tuesday, February 9, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
joseluispauld

Total Points: 13
Total Questions: 132
Total Answers: 98

Location: Venezuela
Member since Sat, Apr 24, 2021
3 Years ago
;