View Full Version : Target DIV?
TheJoshMan
08-08-2008, 09:25 PM
Hey, I'm already pretty sure that this isn't possible... But there's no harm is asking to be sure.
Is it possible to "target" a DIV or other container such as SPAN or something?
Like this:
<div id="nav">
<a href="blank.html" target="content">Content</a>
</div>
<div id="content" name="content">
This is where the content goes...
</div>
Nope, the only way to do that is through XMLHttpRequest.
DD has plenty of scripts for this purpose, eg. http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
TheJoshMan
08-08-2008, 09:35 PM
PERFECT!
Thanks, I kinda thought it was going to be an ajax thing... but I wasn't sure.
Medyman
08-09-2008, 04:48 PM
PERFECT!
Thanks, I kinda thought it was going to be an ajax thing... but I wasn't sure.
Look into using something like jQuery (http://docs.jquery.com/Ajax). It's super-duper-simple to do Ajax calls with it.
From the documentation:
Retrieve the latest version of an HTML page.
$.ajax({
url: "test.html",
cache: false,
success: function(html){
$("#results").append(html);
}
});
Also just noticed that DD has some scripts that might be of interest here:
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
http://www.dynamicdrive.com/dynamicindex17/ajaxincludes.htm
TheJoshMan
08-09-2008, 06:41 PM
Thanks Medyman, I'm already attempting to use one of those scripts.
css-mfc-pro
02-29-2016, 11:12 AM
I know it is a very old topic but like myself anyone can land on this page searching for an answer, a solution.
Well it is possible to navigate to a section of the content from the same page or from content posted on external page
<div id="nav">
<a href="#content">Content</a>
</div>
<div id="content" name="content">
This is where the content goes...
</div>
If the above example the content div is in the same page as the navigation element
<div id="nav">
<a href="http://www.dynamicdrive.com/forums/#footer_time">Content</a>
</div>
<div id="content" name="content">
This is where the content goes...
</div>
The above example is using this forum's footer div as targeted link. The target link attribute is used as tab , _blank, _new, _top and not to call or define the html element
This link goes (http://www.dynamicdrive.com/forums/#footer_time) to the footer section from another page
molendijk
02-29-2016, 12:22 PM
Not tested:
jQuery:
<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div id="nav">
<a href="javascript: void(0)" onclick="$('#content').load('yourfile.html'); return false">Content</a>
</div>
<div id="content" >
This is where the content goes...
</div>
</body>
Without jQuery:
<head>
...
</head>
<body>
<div id="nav">
<a href="javascript: void(0)" onclick="document.getElementById('content').innerHTML=frames.content.document.body.innerHTML; return false">Content</a>
</div>
<div id="content" >
<iframe name="content" src="yourfile.html" style="position: absolute; width:0; height:0; left: -100%"></iframe>
This is where the content goes...
</div>
</body>
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.