Pleng, the problem you describe with my suggestion above seems to be that the JavaScript executed by the click handler is running under the context of the main window, rather than the window of the iframe that (presumably) contains the anchor element being clicked. Thus the window being navigated is the window for the entire document, rather than the window for the iframe. Offhand I don't understand why that would be, and that's not the way it works in a simple test case I made up.
I can think of these things to try:
1) Add an anchor element built as I suggested as a first-level child of the iframe, outside of your menu. That's how my simple, working example is constructed. See if that works, while the presumably more complex example you're currently using does not. If so, try to figure out what's different.
2) Try harder to force the navigation to affect the iframe's window, rather than the main window. Since for some reason the anchor element's click handler is running in the context of the main window, add a navigation function to the main window. So constuct the anchor so:
<a href="next.html" onclick="navigateFrame(this.href); return false">next</a>
Implement that function in the main window
function navigateFrame(url) {
var w = document.getElementById("thatPeskyFrame")
w.contentWindow.location.replace(url)
}
and of course if you do it as I've suggested, you'll have to tag the iframe in question
<iframe id="thatPeskyFrame" etc.>
All this is the same as my earlier suggestion, but it's targeted explicitly at the iframe.
Note that contentWindow is a well documented member of the iframe DOM element. It's a Microsoft standard, not a W3 standard. However I think it's supported by all browsers. Firefox supports it. I haven't tried Opera, but Opera tries hard to be IE-compatible. I don't know about other browsers. On the other hand, if the script fails for any reason, it will fail gracefully and simply navigate the main window using the default method. That will give you history entries, but at least it will work.
3) The window.history object can be navigated back more than one element at a time. You could live with the undesired URL history being added to the main window, keep track of the number of history entries the user has caused to be added, and change your Back button's script so that it skips back that number of entries. You won't be able to manipulate the browser's Back button. I can't imagine that any browser would allow HTML content to affect its behavior.