Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Frarmes and the mildly irritation back button issue-kindly help

Status
Not open for further replies.

cfusiondeveloper

Programmer
Mar 23, 2005
16
0
0
NL
Hello everybody, I'm sure this problem has been discussed before in this forum but I can't seem to find any thread. I am building a site that uses frames. The site uses 3 fames, top nav, left nav and right nav.

Code:
<frameset rows="140,*" frameborder="no" frameborder="2" framespacing="0" border="0">
	<frame src="#TopFrame#" name="nav" scrolling="no" noresize>
	<frameset cols="330,*" id="reader" frameborder="no" frameborder="0" framespacing="0" border="0">
		<frame src="#LeftFrame#" name="TOC" scrolling="no" noresize marginwidth="0">
		<frame src="#RightFrame#" name="content" scrolling="no" noresize>
	</frameset>
</frameset>

If I move to part-way down a page on the frame labelled "content" (perhaps via a link to an internal anchor) then go forward to another page, pressing the back button returns me to the top of the previous page, rather than to the point where I was.

Is there a way to force the browser to take me to the point where I left?

I would really appreciate your help

Best regards
cfcoder
 
>>"Is there a way to force the browser to take me to the point where I left?"

sure - lose the frames. you can't control how the browser's back button works.


-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
sure - but there must be some way to force the frame to scroll down to the point where it last was. I've heard the replace() function can do this but don't know how to use it, any thoughts
 
This is an idea - it may need some work to make useable.

I'm not sure about the onclick. It may need addAttribute or something.

Code:
<script language="JavaScript">

var falseHistory = new Array();
var links = document.getElementsByTagName('A');

for (c=0, c!=links.length, c++){
links[c].attachEvent='onclick, addToFalseHistory';
}

document.body.onunload = checkFalseHistory();

function addToFalseHistory(){
falseHistory.push(event.srcElement); // MSIE only?
}

function checkFalseHistory(){
if (falseHistory.length > 0){
scrollIntoView(falseHistory.pop());
return false;
}
}

</script>

Anyway, it is an idea and hopefully useful to you. I would be pleased if it works :)

Maybe there is an easier way?

----------
Memoria mihi benigna erit qui eam perscribam
 
The replace() function regards regular expressions. Unless I completely misunderstood the request, I don't think it applies to your problem.

----------
Memoria mihi benigna erit qui eam perscribam
 
Found this on the O'reilly website JavaScript: The Definitive Guide, 3rd Edition which made me think the replace button had the answer to this problem.


The replace() method loads and displays a URL that you specify. But invoking this method for a given URL is different than assigning that URL to the location property of a window. When you call replace(), the specified URL replaces the current one in the browser's history list rather than creating a new entry in that history list. Therefore, if you use replace() to overwrite one document with a new one, the Back button does not take the user back to the original document, as it does if you load the new document by assigning to the location property. For web sites that use frames and display a lot of temporary pages (perhaps generated by a CGI script), using replace() is often useful. By not storing temporary pages in the history list, the Back button becomes more useful to the user.


13.8 The Location Object

stormbind - thanks for supplying the code but the problem I'm having is not limited to anchor tags. Its a frame related issue.

Regards,
cfcoder
 
Now trying the document.location.replace() thingy..

This applies only to the one frame, but if it works, the same concept can be adapted to work across frames aswell.

Code:
var links = document.getElementsByTagName('A');

for (c=0, c!=links.length, c++){
links[c].href = 'javascript:document.location.replace(\''+links[c].href+'\')';
}

The idea is to read all <A href="...">links</A> and change them so that they become <A href="document.location.replace('...')">links</A> without messing up browsers that have JS disabled.

But, it's just an idea with no warranty ;)

----------
Memoria mihi benigna erit qui eam perscribam
 
I'm pretty sure you have to cast the link as javascript when using this method stormbind:
Code:
<A href="[b]javascript:[/b]document.location.replace('...')">links</A>

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
[banghead]
 
Uh, sorry, I was quick to use your replace() idea but I don't see how it solves your problem... humn...

Can I see your website?

----------
Memoria mihi benigna erit qui eam perscribam
 
kaht, that is what I did?!

----------
Memoria mihi benigna erit qui eam perscribam

Contact me via profile
 
kaht, that is what I did?!
Again I'm guilty of only reading part of the thread. Guess I'm just lazy today. I posted my response after reading the lower part of your post:
The idea is to read all <A href="...">links</A> and change them so that they become <A href="document.location.replace('...')">links</A> without messing up browsers that have JS disabled.

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
[banghead]
 
I'm afraid the site is not live. I'm having problems taking the user to the very exact location in the page when the back button is clicked. There must be something I could check on load. I just don't know javascript too well. I'm sorry I'm asking a lot of help here.

Regards
cfcoder
 

If I move to part-way down a page on the frame labelled "content" (perhaps via a link to an internal anchor)

Have you tried using an anchor, or was this just a possibility you were thinking about (you say "perhaps")? It might well work.

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
thanks for replying to my thread. The problem I'm having is not limited to anchor tags. I am always taken to the top of the page in the frame (right frame). For example, if I am half way through reading an article displayed inside a right frame and click on another link on left frame and hit the browser "back" button to go back to the previous article. At the point I want the browser to take me to the place where I left. I hope this is making sense

Regards,
cfcoder
 

Then I can only echo Jeff's sentiment from the second post in this thread:

jemminger said:
you can't control how the browser's back button works

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
cfusiondeveloper

"If I move to part-way down a page on the frame labelled "content"..."

I am not clear how you could move part way down a page when you have all 3 frames set to scrolling=no.

However, you can return to a point on any page whether part of a frameset or not by capturing the position of the scroller onunload to a cookie and loading it onload.

You can find a javascript example of doing that in
Clive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top