Jump to content
Sign in to follow this  
yoshida

Add AJAX page to favorites

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?

Share this post


Link to post
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 :) )

Share this post


Link to post
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/

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...