Javascript Ajax Anchor down to Div

I have this Ajax script that I pick up on the Internet, how could I make it Anchor down to the Div Onclick.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
I personally wouldn't use it.  Get your hands on jQuery and use it for your ajax requests.  It will also make it incredibly simplier to use



see jquery api for more details

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
how could I make it Anchor down to the Div Onclick.
Please explain what you mean by this statement.
Michel PlungjanIT ExpertCommented:
I am also not sure, but I am sure that the script is ugly and the invocation using javascript: href even more so.

Load jQuery and add this to the head of the page

$(function() { // page load
  $("#loadLink").on("click",function(e) {
    e.preventDefault(); // stop link

Open in new window

where the link is

<a href="wcstory....." id="loadLink">....</a>
how could I make it Anchor down to the Div Onclick.

Check lines 36 and 42 :
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at for full source code

var bustcachevar=1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects="";
var rootdomain="http://"+window.location.hostname;
var bustcacheparameter="";

function ajaxpage(url, containerid){
	var page_request = false;
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
		page_request = new XMLHttpRequest();
	else if (window.ActiveXObject){ // if IE
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP");
		catch (e){
				page_request = new ActiveXObject("Microsoft.XMLHTTP");
			catch (e){}
		return false;
		loadpage(page_request, containerid);
	if (bustcachevar) //if bust caching of external page
		bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()'GET', url+bustcacheparameter, true);
	return false;

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) {
		setTimeout(function() { location.hash = "#"+containerid; }, 50);

function loadobjs(){
	if (!document.getElementById)
	for (i=0; i<arguments.length; i++){
		var file=arguments[i];
		var fileref="";
		if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
			if (file.indexOf(".js")!=-1){ //If object is a js file
				fileref.setAttribute("src", file);
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
		if (fileref!=""){
		loadedobjects+=file+" " //Remember this object as being already added to page

Open in new window

Check this :
Zepto is a minimalist JavaScript library for modern browsers with a largely jQuery-compatible API. If you use jQuery, you already know how to use Zepto.

how could I make it Anchor down to the Div Onclick.
Below, like this : setTimeout(function() { location.hash = containerID; }, 10);

Check this page:
<!DOCTYPE html>
	<style type="text/css">
		#go {
		#contentarea {
	<script type="text/javascript" src="//"></script>
	<script type="text/javascript">

		var loadedobjects = "";
		var rootdomain = "http://"+window.location.hostname;

		Zepto(function($) {

			function ajaxpage(event){


				var bustcachevar = 1; //bust potential caching of external pages after initial request? (1=yes, 0=no)
				var bustcacheparameter = "";

				var containerid = $(this).data("containerid");
				var url = $(this).attr("href");
				function loadpage(page_request) {
					var containerID = "#" + containerid;
					setTimeout(function() { location.hash = containerID; }, 10);

				$.ajax({ cache: !!bustcachevar, url: url, success: loadpage });



	<a id="go" href="wcstory.cfm?eid=#qwebcastprofiles.eid#" data-containerid="contentarea">MY PAGE TO LOAD WITH AJAX</a>
	<div id="contentarea"></div>

Open in new window

smares323Author Commented:
Good advice.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.