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

  • Always deploy RSH from a local or remote web server. It will not function properly from a file: URL on your workstation - especially in IE. This is true of lots of DHTML applications, but especially true of RSH.
  • Always call dhtmlHistory.initialize() and dhtmlHistory.addListener() from within a window.onload event. RSH will break, especially in IE, if you try to initialize it from any flavor of DOMContentLoaded. IE doesn't load up its saved cross-session form values until just after the body.onload event, so DOMContentLoaded is not an appropriate event for the initialization of RSH.
  • Always include blank.html in your RSH deployment. The library will simply not work without it. It is recommended that you serve blank.html from the same directory as rsh.js; otherwise you'd have to modify the library's source code. A future version of RSH will support a configurable location for blank.html. However, due to cross-domain-scripting issues, blank.html must be served from the same domain as the rest of your application's HTML pages (though you can server your JS from a separate domain). In other words, if your site runs on www.foo.com, blank.html must run on ww.foo.com even if rsh.js runs on foo.someotherdomain.com.
  • RSH ships with a default JSON parser (json2007.js) that adds methods to Object.prototype, Function.prototype, Array.prototype and other core JS objects. For users who would prefer a less intrusive set of JSON utilities, swap in json2005.js - an optional, alternative library that's also included - and deploy using the instructions below.
  • Users of Prototype, jQuery and other Ajax libraries may leave out both JSON parsers and use the JSON utilities from their own libraries instead. Again, see deployment instructions below.
  • No need to include rshTestPage.html or rshTestPageTop100.opml, which merely provide a test suite for you to play with.
  • If your supported browser list differs from RSH's, you should perform browser detection in your own code. RSH does nothing to disable itself in any browser, but it may fail in unexpected ways in unsupported browsers.

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 jailbirt, 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.


Sign in to add a comment
Hosted by Google Code