View Full Version : Ajax Dynamic page open from another

09-27-2006, 06:33 AM
1) Script Title: Ajax Dynamic PAge
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
3) Describe problem: Want to load a page from hyperlink.

I would like to be able to open one of the Dynamic pages from a hyperlink outside my page using the above so that when the person entering is presented with the info without having to click a menu choice.

Can this be done if so what is the syntax

09-27-2006, 11:47 AM
I think you want to do what I just solved a few days ago here on the forum. Maybe it's the solution you are looking for. Try out http://www.dynamicdrive.com/forums/showthread.php?t=13314 and see if this will do the trick. You can call an ajax page with a URL, something like http://www.somesite.com/ajaxpage.html?page=newtopic and ajaxpage.html will come up with the file contents of 'newtopic.html' imbedded in the page already. The same URL can be used in any reference, even generated by javascript. If the URL doesn't have the parameters passed, then a default choice can be made to display.

I use this to seed the page display and to select which menu to display on the page, making a versitile frame that works for many different sets of content. Saved about 6 pages into 1 for me.

09-28-2006, 05:35 AM
thank you.

My only problem is that it is not working, or has done so intermittantly, in IE6, tho workinf fine in Firefox.

I am not that proficient with javascript and have don the following

the two functions I have placed between script tag in the header section and the windows.onload call just after the body tag.

Is there anything else?



09-29-2006, 01:32 PM
It works fine for me in all browsers if everything is in the <head> section, like this:


/* your meta tags go here */

<script type="text/javascript">

/* you can place other javascript functions here if you need */

function getQueryValue(name) {var match = (new RegExp('[?&;]' + name + '=([^&;#]*)')).exec(document.URL);
return match ? unescape(match[1]) : null;

function loadstart(){
var page = getQueryValue('page');
if(page != null)
ajaxpage(page, 'contentarea');
ajaxpage('./default.html', 'contentarea');

window.onload = loadstart;

'default.html' should be replaced with the name of your default content for a nomal page entry. External page calls from a url in the form of:
<p>Click <a href="./displayajaxstuff.html?page=specialpage.html>here</a> to see for yourself!</p>This means that the getQueryValue function looks in the URL for the string 'page' (but you could use something else if you want) after the question mark , and retrieves the associated string, then places it in the ajaxpage function argument, which then fills the page with the requested content. You also must make sure that your <div> id is the same as that used in the ajaxpage() function call inside function loadstart() - in the above case it is called 'contentarea'. The last assumption is that both 'default.html' and 'specialpage.html' are in the same directory as the 'displayajaxstuff.html' and the external calling page. If they aren't, then you have to change the paths correctly..... I hope this will get you going.

10-03-2006, 12:40 AM

I have installed my code on our webserver, as distinct from the testing server, and all is fine so...??

Thanks again