yoshida Posted October 15, 2007 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? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 15, 2007 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 Link to comment Share on other sites More sharing options...
yoshida Posted October 17, 2007 Author 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 ) Link to comment Share on other sites More sharing options...
Synook Posted October 18, 2007 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/ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.