<div> linking

liunx

Guest
Hi, I've created a <div> based page,

What i want to do it from a link in one div - (left hand side) to open a page within another div (a main section)

At the mo, I have:

<div id="menu">
<p><a href=http://www.webdeveloper.com/forum/archive/index.php/"blue_popup.htm" target="core">Vitals</a></p>
</div>

<div id="juice" name="core">
</div>

What am i doing wrong because the link opens a new page.

rEdI don't think you can transfer data like this between divs. you need to put an iframe in your target Div, and set the name of the iframe to be your target.

daveActually it is very possible and relatively easy to load a new page in a div on the same page as the original link.

1- build your original page with DIVs and create an empty DIV where you content will appear later. name the page "page1.asp"

2- create the linksand add a query string to each one, like so:
<a href=http://www.webdeveloper.com/forum/archive/index.php/"page1.asp?content=1">biography page link</a>
<a href=http://www.webdeveloper.com/forum/archive/index.php/"page1.asp?content=2">FAQ page link</a>

3-once this link is clicked, the same page will reload, but it will have a querystring on the URL "content=1"

4- right before your empty DIV, write some ASP script as follows:
<%
'declare my variables
Dim content_qs, load_url
'retrieve my querystring and put it in an ASP variable
content_qs = Request.Querystring("content")
'depending on which querystring was retrieved, surf to a specific page
If (content_qs="1") Then
load_url = "bio.asp"
ElseIf (content_qs="2") then
load_url = "faq.asp"
End If
%>

5-Now in the empty DIV, you must place a Server.Execute() function (ASP) to load your chosen page into the DIV on the server side, before the page gets to the browser, like so:

<% 'the "equal" sign below means write the value of the variable "load_url" to the page %>
<div><% Server.Execute(=load_url) %></div>

6- This is what will happen:
a)You will click a link
b) the same page will reload with a querystring on the URL
c) you grab the querystring
d) Depending on the querystring value, a specific page name will be placed into an ASP variable
e) the variable value is placed on the page inside an ASP function that will load the content of the desired page into the DIV area
f) the result is that page2.asp is merged onto page1.asp in a div, so it looks like your are using frames even though you are not ;).

7-note for more advanced ASP users: I did not use a subroutine for simplicitywhat if the server is *nix, odds are it is:o sorry, I made a little mistake in my code:

In the empty DIV, it should be as follows:

<div><% Server.Execute(load_url) %></div>

There is no "equal" sign before the "load_url" variable.I am pretty sure that PHP would have a finction similar to server.execute.

I'll try to find something, but no guarantees.i know there is but that person just wasted that time, why not ask him/her first what server it is... im sorry, its 3am here an im gettin annoying :S

but yeh, for php it easier i rekon to use include();
i posted some about this today already if you wanna search it.

But, Without using any scripting then it is not possible to do what the original question asked unless you do use an iframe, but avoid that if possible (iframes & frames eeekk).

Mmmk.Ok, the PHP "equivalent" to the ASP server.execute is:

include()


Example:

<?
if ($page=="1")
{
include("nav/navigation_index.php");
};
?>

Not too sure about the syntax (it is a cut and paste)No problemo. I know how it is working at 3am... been there, done that :)

I don't think it is wasted time though, Someone else will always need similar code.

The principle is the same in most server-side languages, as well.

Gotta run!The linking method works using this but I get the following error in the original <div> (ie. before link is clicked).

Server object error 'ASP 0231 : 80004005'

Server.Execute Error

/cw/newsletter_cw/page1.asp, line 150

Invalid URL form or fully-qualified absolute URL was used. Use relative URLs.

I am using the code exactly as above except for a change in the .asp names that I link to.
 
Back
Top