Open GoogleCodeExporter opened 9 years ago
The trick here is that you need to change the title BEFORE you call
history.add();
ideally your code should look like this:
document.title = "some new text";
dhtmlHistory.add(key, value);
During the course of dhtmlHistory.add, the browser will record the current
document
title in the history stack, so if you change it AFTER the add, then everything
will
get one step out of sync when you trigger your history listener with the back or
forwards button.
Glad to clear that up; I've long thought this would make a nice enhancement: the
ability to pass a third value and have that value be the new document title.
That
way, the syntax would be dhtmlHistory.add(key,value,newTitle). To make it even
more
useful, we could add an optional "baseTitle" member that could be passed in
through
the options bundle. That way, if you wanted some sort of site identifier at the
front
of every title, you wouldn't have to pass it in every time.
Keeping this ticket open as an enhancement because this should be easy and
useful for
me to implement.
Original comment by bdpathfi...@gmail.com
on 20 Nov 2007 at 10:18
I did what you said but I think that still something changes when you use the
browser
buttons. Cause I click go to the previous page and then change the title. But
the
browser has already taken the wrong title in the history. I think the problem
is that
you are polling al the time if the browser has changed and when it has already
changed then you trigger the historyEvent. But before the browser has already
copied
the wrong title in his system.
Original comment by elmos...@gmail.com
on 21 Nov 2007 at 9:40
I found a solution at least for me it works. Every time when you add or have a
historyEvent. Do everything you want and then change the title with a delay,
like
50ms. You change the title and then put the same has by the script again in
document.location.hash. And also I had to add a manually defined hash before I
run
dhtmlHistory. So the start looks like:
window.onload = function() {
document.location.hash = "#HS0:start";
dhtmlHistory.initialize();
dhtmlHistory.addListener(historyChange);
};
var hash = document.location.hash;
if(hash != "") {
document.location.hash = hash;
}
I had to add the first hash because if you put an empty hash in
document.location.hash. The page refresh so you lose the information, that is
needed
for the next page.
Original comment by elmos...@gmail.com
on 23 Nov 2007 at 2:51
I also forgot to tell that I use this framework for a Flex application. So
maybe you
can add this to your project details. Because it can be enabled for Flash and
Flex
application too.
Original comment by elmos...@gmail.com
on 23 Nov 2007 at 2:53
For nice titles in the history box in Internet Explorer. You have to change the
blank.html to a blank.asp or blank.php or whatever you will like. When you add a
history you give an extra variable called "newTitle" and you pass this one in
the
rsh.js "row 231" to:
that.iframe.src = "blank.php?title="+newTitle+"&" + newLocation;
In the blank.??? you grab the posted title and put it in between the
<title></title> tags.
Original comment by elmos...@gmail.com
on 23 Nov 2007 at 7:30
[deleted comment]
[deleted comment]
[deleted comment]
Another change needed, I created a variable for the dummyPage at the beginning
of the
class and changed the following lines.
row 35: dummyPage: "blank.php",
row 232: that.iframe.src = that.dummyPage + "?" + newLocation + "&title=" +
newTitle;
row 338: var iframeHTML = '<iframe frameborder="0" id="' + iframeID + '"
style="' +
styles + '" src="' + this.dummyPage +'?' + initialHash + '"></iframe>';
row 427: this.iframe.src = this.dummyPage + "?" + hash;
Original comment by elmos...@gmail.com
on 23 Nov 2007 at 8:21
Original comment by bdpathfi...@gmail.com
on 29 Nov 2007 at 11:07
Yes, by all means please post your suggested patch. I'm working on this right
now for
RSH 0.8 and am running into lots of cross-browser issues....
Original comment by bdpathfi...@gmail.com
on 3 Dec 2007 at 9:13
Here it is, there are still some sitecode inside but yeah just check what i did
if
you want some extra info just ask. Im also working now so i dont have much time.
Original comment by elmos...@gmail.com
on 4 Dec 2007 at 12:00
Attachments:
So it turns out this is more complicated than we initially thought. See my blog
post
here:
http://blogs.pathf.com/agileajax/2007/12/really-simple-1.html
Original comment by bdpathfi...@gmail.com
on 11 Dec 2007 at 5:31
I read your block and definitely you didnt read my code. You cant be before the
click
event but you can reproduce the action. And then you can change the title on the
right moment. As I told you before I already have it up and running without
messing up.
document.title = title;
// I change the title and put the same hash again the browser will reset the
title
again but this time good.
var hash = document.location.hash;
document.location.hash = hash;
Original comment by elmos...@gmail.com
on 11 Dec 2007 at 6:12
@Elmosgot:
Oops, my bad. I didn't check back here before writing that blog entry and
hadn't seen
your code.
Unfortunately, you are working from code that you forked from 0.6, and I am
working
from the 0.8 branch, so it's hard for me to just plug your code in and test it.
There
have been lots of changes to the 0.8 branch, so I'm having to look at your
techniques
then re-implement them in my branch.
That said, your trick of reloading the hash is totally golden for FF and Safari
3. I
even have the problem licked in IE - WITHOUT having to make server changes to
blank.html. I just added some JavaScript to the head of blank.html to set its
own
title to the parent document's title.
The only places I'm having problems are Safari 2.x and Opera. I'm not sure if
those
problems are related to the title-change code or to other code changes I've
made to
automatically do URI encoding and decoding on history points to that you have
have
hashes with spaces and special characters in them. I'll need to continue work on
this, but thanks to your help I have regained faith that this is possible.
The code I'm working with also doesn't force you to add a hash before
initializing
RSH - at least thus far. That might change depending on my experience with
Safari 2.x
and Opera.
Could you tell me which all browsers you have tested your own code in, including
platform and version numbers?
Finally, RSH 0.8 will allow configurability of the location and filename of
blank.html, so if you still have a compelling reason to make that file a .php
file,
it will be a lot easier.
Thanks again for all your hard work and sorry I hadn't noticed it till after
today's
blog post.
Original comment by bdpathfi...@gmail.com
on 11 Dec 2007 at 11:22
Original issue reported on code.google.com by
elmos...@gmail.com
on 16 Nov 2007 at 8:51