samedi 28 février 2015

How to use onpopstate, with javascript, no jQuery?

I have a website that has 4 main pages, index, somepage, someotherPage, and LastOtherpage. They have different names, like index.php, food_and_health.php, enlightening_info.php, and about_us.php.


I have my ajax part(HTTPrequest) working fine, and the pushstate is working.


What I now want, is obviously, the popstate function working. I have read, and watched tutorials, but how would I do this with the this keyword?


I have a fiddle added, so you can see me code, its not working well in the fiddle, but works very good in chrome, firefox and late ie. I have something like this in mind for my onpopstate..



nav.history("this.object", "Title", "/this.url");
http://ift.tt/1AGAfrP


How would the onpopstate code look like? I know it is bad to ask for all the code, but this way I actually learn, as when I read the code, I understand it. I haven't fully got the grip of javascript eventhandling yet, as you can see I use onclick in my html documentes, and not eventhandling them. But this I know, I can do, it is just a lot of changing in my documents, and first priority for me, would be to have back/forward, refresh, and share functionality to work, so that I can actually share my website out in the web, without and lack of functionality! :)


Any help is much appreciated, thanks in advance :)


Aucun commentaire:

Enregistrer un commentaire