yoshida 0 Posted October 15, 2007 Report Share Posted October 15, 2007 Hi. I'd like to create a button on my Ajax site which says 'add this page to your favorites'.It goes down like this: my links are event triggers which passes a parameter to the script. The page passed in the parameter gets loaded.Now the first lines look like this: function loadMainBody(serverPage) { if (!serverPage) { var serverPage = 'dummy.html'; } How do I add something to favs? Can I also store the event trigger and it's parameter? Quote Link to post Share on other sites
justsomeguy 1,135 Posted October 15, 2007 Report Share Posted October 15, 2007 No, you can't store anything dynamic, a favorite entry is just a URL. You can store querystring parameters but that's it. Check Google to see how.http://www.google.com/search?client=opera&...-8&oe=utf-8 Quote Link to post Share on other sites
yoshida 0 Posted October 17, 2007 Author Report Share Posted October 17, 2007 So then I'll have to propagate the parameter as a variable, and make index.php look for it. (index.php?serverPage=newspost071017)Then set var serverPage='<?php serverPage ?>'Not even going to ask whether it is possible, I'll simply try. And keep the results to myself. (jk ) Quote Link to post Share on other sites
Synook 47 Posted October 18, 2007 Report Share Posted October 18, 2007 I also recently ran across a method of having unique URLs for AJAX pages, without page refreshes, involving the "hash" (#) part of the URL, which even when changed does not cause page refresh, but still give a unique identifier to the URL. Using the location.hash property you can retrieve that value and use it as the guide to retrieve the page through AJAX. A very simple example: <html><head><script type="text/javascript">function load(page) {if (page == "") {page = "home";}window.location.hash = "#" + page;//Establish AJAX object to var xmlHttp//Code for writing called data to screenxmlHttp.open("GET", page + ".php", true);xmlHttp.send(null);}</script></head><body onload="load(window.location.hash.substring(1))"></body></html> You can see a small example of this in action at http://www.roundeddesign.com/roundeddesign_2/ Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.