Jump to content

Add AJAX page to favorites


yoshida
 Share

Recommended Posts

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...