PDA

View Full Version : Loading a link into a DIV



Recursion
17-04-2010, 07:53 PM
Hey,

I have a link on a web page where I would like it to load the linked page into a specific DIV on my site.

Does anyone know how to do this? I assume some JS/AJAX will be involved but I wouldn't know where to start.

Thanks :)

iDenning
17-04-2010, 07:56 PM
use ajax

http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

i think that is correct link.

Recursion
17-04-2010, 08:04 PM
I tried it but it just refused to work :S

iDenning
17-04-2010, 08:06 PM
show code that you did, should work so you must of did wrong :P

Recursion
17-04-2010, 08:15 PM
Ok, I don't think I really need to show you the head code, I just copy pasta'd it into the head, but heres the link code..


<a href="javascript:ajaxpage(rootdomain+'/static/privacy.php', 'content');">privacy1</a>

iDenning
17-04-2010, 08:29 PM
Did you name the div 'content' ?


Ok, I don't think I really need to show you the head code, I just copy pasta'd it into the head, but heres the link code..


<a href="javascript:ajaxpage(rootdomain+'/static/privacy.php', 'content');">privacy1</a>

Recursion
17-04-2010, 08:31 PM
Did you name the div 'content' ?

Yes :P

Apolva
22-04-2010, 09:56 PM
Use jQuery, it's much better than the other AJAX / Javascript effects classes IMO.

http://jquery.com/

Just include the script include, then do:

<a href="javascript:$('#div_id_here').load(rootdomain+'/static/privacy.php');">privacy1</a>More info about the jQuery load() function:
http://api.jquery.com/load/

Edit - Just a second note, with AJAX, the requested page has to be on the same domain/subdomain.

MattFr
23-04-2010, 05:58 PM
XMLHTTPRequest, job done.

Adamm
23-04-2010, 08:25 PM
XMLHTTPRequest, job done.
Way to explain clearly.

MattFr
24-04-2010, 08:38 AM
Way to explain clearly.
I'm a strong believer of people learning things on their own, not just been spoon fed working code. I appreciate your concern though ;)

Adamm
24-04-2010, 10:15 AM
I'm a strong believer of people learning things on their own, not just been spoon fed working code. I appreciate your concern though ;)
Like giving a 1 year old a book and expecting it to learn the language?

Brilliant.

MattFr
24-04-2010, 10:43 AM
Like giving a 1 year old a book and expecting it to learn the language?

Brilliant.
I'm loving your creative analogy but it's not really the same, is it? If he is able to code some basic languages already, it's pretty easy to pick things up; I certainly did this with Actionscript 3. Sorry that my inferior mind doesn't comprehend the same logic as yours, but I am sure we can stop pushing this further off-topic now :)

Recursion
16-05-2010, 07:14 PM
Use jQuery, it's much better than the other AJAX / Javascript effects classes IMO.

http://jquery.com/

Just include the script include, then do:

<a href="javascript:$('#div_id_here').load(rootdomain+'/static/privacy.php');">privacy1</a>More info about the jQuery load() function:
http://api.jquery.com/load/

Edit - Just a second note, with AJAX, the requested page has to be on the same domain/subdomain.

Thanks for the help, but it still isn't working :S



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Administration Panel</title>
<link REL="stylesheet" href="adminstyle.css" media="screen" type="text/css" lang="en"/>
<script type="text/javascript" src="../jquery-1.4.2.js"></script>
</head>
<body>

<div id="AdminIn2Nav">
<a href="javascript:$('#AdminIn2Content').load(rootdomain+'/content/home.php');">Admin Home</a> <br />
<a href="javascript:$('#AdminIn2Content').load(rootdomain+'/content/userman.php');">User Manager</a><br />
</div>

<div id="AdminIn2Content">
</div>

</body>
</html>

XMLHTTPRequest, job done.

Helpful! :X

Apolva
16-05-2010, 11:29 PM
Try this instead:


<a href="javascript:void(0);" onclick="$('#AdminIn2Content').load('content/home.php');">Admin Home</a>


If not, link me the page you're having problems with.

Recursion
17-05-2010, 06:03 AM
That did it, thanks! :)

Gunna have to look into this JQuery stuff :P

Want to hide these adverts? Register an account for free!