My favorites | Sign in
Project Logo
                
Search
for
Updated Dec 10, 2007 by bdpathfinder
UsageInstructions  
Basic installation instructions for RSH.

These instructions are for RSH 0.6. For deployment of 0.4, see the release notes for that version.

How to deploy Really Simple History

Deployment examples

Default install with json2007.js

<script type="text/javascript" src="json2007.js"></script>
<script type="text/javascript" src="rsh.js"></script>

<script type="text/javascript">
window.dhtmlHistory.create();

var yourListener = function(newLocation, historyData) {
	//do something;
}

window.onload = function() {
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(yourListener);
};
</script>

Install for users of json2005.js

<script type="text/javascript" src="json2005.js"></script>
<script type="text/javascript" src="rsh.js"></script>

<script type="text/javascript">
window.dhtmlHistory.create({
	toJSON: function(o) {
		return JSON.stringify(o);
	}
	, fromJSON: function(s) {
		return JSON.parse(s);
	}
});

var yourListener = function(newLocation, historyData) {
	//do something;
}

window.onload = function() {
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(yourListener);
};
</script>

Install for users of prototype.js

<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="rsh.js"></script>

<script type="text/javascript">
window.dhtmlHistory.create({
	toJSON: function(o) {
		return Object.toJSON(o);
	}
	, fromJSON: function(s) {
		return s.evalJSON();
	}
});

var yourListener = function(newLocation, historyData) {
	//do something;
}

window.onload = function() {
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(yourListener);
};
</script>

Comment by solovey.alexander, Nov 25, 2007

For prototype users this code can be look more pretty

window.onload = function() {
        dhtmlHistory.initialize();
        dhtmlHistory.addListener(yourListener);
};
Event.observe(window, 'load', function() {
        dhtmlHistory.initialize();
        dhtmlHistory.addListener(yourListener);
});
Comment by al.james, Dec 21, 2007

For MooTools? users:

window.dhtmlHistory.create({

toJSON: function(o) {
return Json.toString(o);
} , fromJSON: function(s) {
return Json.evaluate(s);
}
});

Comment by atregoubenko, Jan 30, 2008

better options hash for prototype: {toJSON: Object.toJSON, fromJSON: String.prototype.evalJSON}

Comment by nahuelbulla, Feb 11, 2008

Hi can anyone tells me how I can deploy rsh with jQuery ??? tks!!

Comment by walkerfiles, Feb 14, 2008

For prototype users:

fromJSON: String.prototype.evalJSON, as prescribed in the previous post, gave me this error:

this.unfilterJSON is not a function

so I recommend using, fromJSON: function(s) {return s.evalJSON()}, as outlined at the top

toJSON: Object.toJSON does work, though

Let me know if you find otherwise...

Comment by fab.galtier, Feb 20, 2008

I have tested the example bundled but it does not work with IE6 : "blank.html - Needed for Internet Explorer's hidden iframe" It is strange because the blank.htmpl page is present in the example's directory. Thaks for your answer.

Comment by manojgorasya, Mar 12, 2008

please tell me the proper way to implement it in my application

Comment by jailb...@gmail.com, Mar 16, 2008

Hi, i have this error: Object.toJSON is not a function. I have prototype working, which version is recomended, this is by prototype?

thanks.

Comment by dericbytes, Apr 07, 2008

Hear's some implementation information I would have found useful

; Save details needed to recreate the current pages status. dhtmlHistory.add(currentLocation, 'some data');

; Restore the current page, when the back button is clicked var yourListener = function(oldLocation, historyData) {

var historyMsg = (typeof historyData == "object" && historyData != null

? historyStorage.toJSON(historyData) : historyData

);

var msg = "A history change has occured:\n oldLocation=" + oldLocation + "\n historyData=" + historyMsg ;

// myRestorePage(oldLocation, historyData)

alert(msg);

};

Comment by rakesh.sankz, Apr 29, 2008

I'm having a problem safari like this: "Maximum call stack size exceeded." in json2007.js file.

Do anyone had this problem before?

Any help would be appreciated.

Comment by overnoise, May 13, 2008

I can find the function to deploy rsh with jQuery! Please Help!

Comment by zacharyrubin, May 13, 2008

Overnoise, please be more specific. I made it work with Jquery and prototype but it was a pain.

Regards Da Zack

Comment by overnoise, May 16, 2008

Hi Zack! I'm sorry you are right...I have problems with json2007 and jquery 1.2.3 (also 1.2.2) and this is a known issue...so...which function did u used instead of ToJson? and FromJson?, defined in json2007.js ?

Comment by david.schissler, May 30, 2008

overnoise, I used http://www.JSON.org/json2.js with jquery 1.2.5 and it seems to work. You initialize with the library for dhtmlHistory the same as json2005.js

window.dhtmlHistory.create({ toJSON: function(o) { return JSON.stringify(o); } , fromJSON: function(s) { return JSON.parse(s); } });

Comment by andrzej....@javatech.com.pl, Jun 15, 2008

Can somebody tell me why when I'm using the prototype then Ajax.Updater(...) doesn't work?

Comment by laruiss, Jul 14, 2008

Every thing works with almost every browser (Gecko based, Opera, ie6+), except Safari/Mac : I get "unmatched </head>" and "extra <body> encountered" errors, when I write this in head :

window.dhtmlHistory.create({
        toJSON: function(o) {
                return Object.toJSON(o);
        }
        , fromJSON: function(s) {
                return s.evalJSON();
        }
});

How do you make rsh compatible with safari ?

Comment by dpnewman, Jul 17, 2008

wanting to thanks the creators of this ... best solution i have found for this very important functionality.

excited for coming releases and safari support etc.

Comment by megachan, Aug 05, 2008

FYI:You need at least 1.5.1 Prototype to get Object.toJSON method...

Comment by dpnewman, Aug 08, 2008

has anyone gotten this to work with safari mac 3.1.2? frustratingly difficult for me so far. works like a charm in ff.

in safari, when i call dhtmlHistory.add(..) for the second time ... i get an infinite looping back and forth between the 1st 2 saved history points.

Comment by Kevin.Fat.Chen, Aug 10, 2008

does this work with ASP.NET Ajax?

I have got sys.application is null for default installation.

I have got no error with Json2005 installation, but nothing gets added to the history....

I have got a few update panel and I install things to my MasterPage?.... are there things I need to do to each individual update panel?

Comment by bipinkadam, Sep 06, 2008

Hi kevin, I had same problem as u mentioned. Did u got any solution

Comment by aljino...@upload.com.hr, Sep 27, 2008

if anyone tries to implement RSH and TinyMCE editor, strange behavior (js errors, duplicate editor) will be caused because RSH uses hidden textarea form element.

Solution: change it inside RSH to something else, like: <input type="text"></input>.

Comment by forti...@gmail.com, Nov 14, 2008

I have everything working fine in safari and FF but IE7 crashes when i click the refresh button!! does anyone know why? has anyone have this problem?

i have blank.html in its place! and i call the initialization in window.onload

Comment by satishsapate, Nov 25, 2008

Hi to all, can someone help me.... I was follows same procedure in my project but it does not show browser back button on mozilla but it shown on IE but when i click on back button it does not go on back history. Thanks.

Comment by snsanju, Dec 10, 2008

Hi, i am using cakephp framework for my application, and using scriptaculous and prototype. I really not getting any idea about how to implement simplehistory with cakephp. my application is completely ajax driven. Thank you

Comment by asimalp, Dec 11, 2008

To get it working in Safari 3.1, read this:

http://code.google.com/p/reallysimplehistory/issues/detail?id=62

All you have to do is to modify rsh.js line 61 as follows:

} else if (vendor.indexOf("Apple Computer, Inc.") > -1 && parseFloat(navigator.version) < 3.0) {

Comment by hoopsnerd, Jan 13, 2009

Anyone have any better instructions for implementing this? I'd love to use it but I'm not sure how to merge it into my own AJAX application.

Thanks!

Comment by manoj.bhatty, Jan 23, 2009

Step by step instructions of implementing RSH with jquery and JSON2007 - http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html

Comment by jonranes, Jan 28, 2009

I finally got this thing working in ie and firefox. I did the safari mod mentioned above and my application now works on safari but the back button functionality doesn't work. Anyone else have this?

Comment by knad05, Feb 18, 2009

Working perfectly with prototype 1.6.0.3 in FF (3.0.6) and Chrome (2.0.162).

I use:

window.dhtmlHistory.create({ //Use prototype JSON methods 
    toJSON: function(o) { return Object.toJSON(o); },
    fromJSON: function(s) { return s.evalJSON(); } 
  });

//Event Observations 
Event.observe(window, 'load', function() { //Initialize RSH 
    dhtmlHistory.initialize(); 
    dhtmlHistory.addListener(load); //On history change, call 'load' function 
}); 

With my 'load' function being:

load = function(page) {
  new Ajax.Updater('main', page, { method: 'get', evalScripts: true }); 
  dhtmlHistory.add(page); return false; 
 };

Hope this helps someone!

Comment by jmalinsky, Feb 18, 2009

@knad05

Thanks, your example was really helpful. Nice timing, too... I fear I'd be out of luck had you not posted today! I did, however, change the function name. Not sure 'load' is so kosher.

Thanks again

Comment by csaladna...@t-online.hu, Feb 22, 2009

For me this code works very slowly, especially in IE (tried all json.js):

window.dhtmlHistory.create({ toJSON: function(o) { return Object.toJSON(o); }, fromJSON: function(s) { return s.evalJSON(); } });

It takes a lot of time for rsh to add data to historyStorage (dhtmlHsitory.add also), and during data adding IE does not respond to user input. When the historyStorage grows bigger, the adding takes more and more time.

For me this code solved the problem in IE:

window.dhtmlHistory.create({ toJSON: function(o) { return JSON.stringify(o); } , fromJSON: function(s) { return JSON.parse(s);} });

But I have problems in FF3. I don't know if this is json's, rsh's or FF3's fault but the CPU is 100% when adding data to historyStorage. And is getting worser as the historyStorage grows. Anyone has any idea?

Comment by t...@interdirect.co.uk, Mar 13, 2009

I cannot get this to work in IE7 for love nor money. The event I assign to addListener is never fire off when I press the back button. My code is identical to the last of http://www.onjava.com/onjava/2005/10/26/examples/examples/oreillymail/oreillymail.html. This link works perfectly for me in IE7 but my copied code (Copied source, copied the two JS files and the one CSS file) will not work. Works fine in FF3, just IE7.

Please someone help me :(

Comment by mathewj, Apr 27, 2009

IE6 / IE7 rendering issues with rsh:

When i tried to use rsh on IE6/7, the browser stop rendering the page, there are some special characters (few marks) shown on the browser, not the real content. But it works fine on FF3. I am using prototype 1.6 with rsh 0.6 libraries. It doesn't work even if i use the json2007.js instead of the prototype lib.

Any Idea ?

Comment by salinebattersons, May 02, 2009

I'm using mootools and have had no luck implementing RSH. I tried the window.dhtmlHistory.create posted for mootools users by al.james, still no dice.

Anyone using mootools have RSH working properly?

Comment by strubester, May 03, 2009

http://groups.google.com/group/reallysimplehistory/browse_thread/thread/9ea66d8d5c5634b1 has a great post on how to use jQuery for JSON -- helped me resolve conflicts.

Comment by wael34218, May 04, 2009

Hi guys, I am developing an ASP website, I tried to use rsh and worked great on one page, but when i tried to use it on a page that has a master page it gives me an error on the line "window.dhtmlHistory.create();" Microsoft JScript runtime error: 'window.dhtmlHistory' is null or not an object

what seems to be the problem?

Thanks

Comment by salinebattersons, May 06, 2009

Why does RSH cause the page to scroll down when clicking on an anchor tag <a>. I would like it if the page would stay stationary. I am replacing a <div> when the anchor is clicked. It worked fine (no movement) until I implemented RSH.

Any feedback would be appreciated. Thanks.

Comment by sanderboele, Jul 01, 2009

@ salinebattersons I've had the same thing, try renaming your anchor points.

Comment by Md.Nauman, Jul 19, 2009

Hi, To improve the perceived performance, I am trying to download in the rsh.js after the page is displayed (code attached below): <script type="text/javascript"> function loadScript(url) { var e = document.createElement("script"); e.src = url; e.type="text/javascript"; document.getElementsByTagName("html")0?.appendChild(e); }

window.onload = function() { loadScript("/rsh/rsh.js"); }

window.dhtmlHistory.create({ toJSON: function(o) { return Object.toJSON(o); }, fromJSON: function(s) { return s.evalJSON(); } });

var historyChange = function(newLocation, historyData) { //do something here } Event.observe(window, 'load', function() { dhtmlHistory.initialize(); dhtmlHistory.addListener(historyChange); }); </script>

But this code is not working. How can I use this code WITHOUT downloading the rsh.js in the HEAD section?

Comment by ponkumarpandian, Jul 20, 2009

Please any one help me to Implement RSH in ASP.NET application... I have followed all method to implement this RSH. Please refer my code as below,

<script type="text/javascript" src="Scripts/json2007.js"></script> <script type="text/javascript" src="Scripts/rsh.js"></script>

<script type="text/javascript"> delete Object.prototype.toJSONString; window.dhtmlHistory.create();

var historyChange= function(newLocation, historyData) { //alert('Test'); //do something; alert('inside listener'); //testHistoryStorage(); }

window.onload = function() { dhtmlHistory.initialize(); dhtmlHistory.addListener(historyChange); log("<b>dhtmlHistory listener created</b>"); };

In historyChange function how store my content.. Please Help !!!!!!!!!!!!

Comment by statikeffeck, Jul 27, 2009

IMPORTANT NOTE for people trying to get this to work with IE6 or IE7. This may be related to the script trying to find "blank.html". Whichever URL & directory you run this script from, it will look for blank.html only in the running directory! Example: if you are using the rsh.js on a page like www.mysite.com/hello/there/test.html, blank.html MUST be located at www.mysite.com/hello/there/blank.html or this will NOT WORK at all in IE 6/7. To get around this I changed the rsh.js source from "blank.html" TO "/blank.html" which allows you to place blank.html in your ROOT directory!!!

Keep this in mind if you have URL re-writes that make the client-side think it is running in a sub-directory.

Comment by minyao88, Sep 17, 2009

I am using the RSH for my project, and now I hit the wall and don't know how to solve the problem. In the ajax call (used to handle paging like page1, page2, page3...), I call the add method like the following: dhtmlHistory.add("page"+pageIndex+"view"+l2ViewType+""+sortBy+""+orderBy+""+pageSize, pageIndex); The initializing code (dhtmlHistory.initialize(); dhtmlHistory.addListener(pageHistoryChange);) is put in the window.onload block.

Everytime, after I click the paging bar (the add function is called inside), pageHistoryChange(newLocation, historyData) will be triggered with newLocation="", and historyData =null.

When I hit the back buttontring to back to the previous page, the pageHistoryChange(newLocation, historyData) will be triggered with parameter : newLocation="", and historyData =null, and the URL will change to #. I hit the back button again, the pageHistoryChange(newLocation, historyData) will be fired with the parameter I wanted: newLocation="page1", and historyData =1, and the URL will change to #page1.

That means if I click on page1, page2, page3, (the url will show as #page1, #page2, #page3), but if I want to go back by clicking on the back button, then the back button click will bring me to #, #page2, #, #page1. I have to click twice to go back to the previous page.

My expected result is click once to back to previous page. That means when I call the add method, the pageHistoryChange shoudn't be triggered with the newLocation="" and historyData =null. Is that true? then how?

Min


Sign in to add a comment
Hosted by Google Code