PDA

View Full Version : Dynamic Content not working



Natasha
10-12-2010, 11:13 AM
1) Script Title: Dynamic Content not working

2) Script URL (on DD): on internal server

3) Describe problem: I want to only load the content of the pages when going to a page i dont want to load header and menus every tine. I have gone through your tutorial on dynamic content but it wont work for me i dont know what i have done workg can soneone see where i am going wrong. Thanks for help in advance.
Code is here for two files

index.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Welcome to the Beacon Hospital</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<link href="layout.css" rel="stylesheet" type="text/css" />

<script language="JavaScript" src="/tools/BeaconMenu/menu.js"></script>
<script language="JavaScript" src="menu_items.js"></script>
<script language="JavaScript" src="menu_tpl.js"></script>
<link rel="stylesheet" href="/tools/BeaconMenu/menu.css">
<script type="text/javascript">

/***********************************************
* Dynamic Ajax Content- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ 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){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
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=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

</script>
<script>
var menuids=["suckertree1"]

function buildsubmenus(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item
else //else if this is a sub level submenu (ul)
ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
ultags[t].parentNode.onmouseover=function(){
this.getElementsByTagName("ul")[0].style.display="block"
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.display="none"
}
}
for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
ultags[t].style.visibility="visible"
ultags[t].style.display="none"
}
}
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus)

</script>
</head>
<body>

<div class="row1">
<div class="container">
<div class="col1">
<img src="images/beacon_logo_intro3.jpg" style="width: 229px; height: 52px" />
</div>
<div class="col2 left">

<script type="text/javascript" language="JavaScript">
new menu (MENU_ITEMS, MENU_TPL);
</script>
</div>
<div class="col3 right">
<a class="Emergency big">Emergency Codes:&nbsp;&nbsp;&nbsp; Blue 2222&nbsp;&nbsp;&nbsp;&nbsp;
Fire 7777&nbsp;<br /> IT Contacts: helpdesk@beaconhospital.ie </a>
</div>
</div>
</div>

<div class="row2">
<div class="container1">
<div class="col4 img2">
<img src="images/hospital.jpg" style="width: 233px; height: 127px;" />

</div>
<div class="col5">
<img src="images/logotest.jpg" style="width: 100%; height: 127px;" />
</div>
</div>
</div>
</div>

<div class="row3">
<div class="container2">
<div class="col6">
<table style="width: 176px; "top" >

<tr>
<td bgcolor= "#006699"><div class="suckerdiv">
<ul id="suckertree1">
<li><a href="javascript:ajaxpage('index.htm', 'col12');"class="style42">Home</a></li>
<li><a href="" class="style42">Email </a></li>
<li><a href="" class="style42">Departments</a>
</li>
<li><a href="" class="style42">Policies &amp; Procedures</a></li>
<li><a href="" class="style42">Forms</a> </li>
<li><a href="" class="style42">Staff</a></li>
<li><a href="" class="style42">Self Help</a></li>
<li><a href="" class="style42">Internal Vacancies</a></li>
<li><a href="javascript:ajaxpage('index8.htm', 'col12');" class="style42" >Staff Benefits</a></li>
<li><a href="" class="style42">Links</a></li>
</li>
</ul>
</td>
</tr>
</table>
</div>

<div id="index.htm" class="col12">
<div class="col7">
<a class="H1">Staff Benefits</a>
<ul>
<li>Employee Referral Bonus</li>
<li>Move to HR</li>
<li>Vodafone Employee offer</li>
<li>Changes in Flexible benefits</li>
<li>Pay Dates</li>
<li>My Hub-Payslips</li>
<li>Payslips Website</li>
</ul>

</div>

</div>
</div>
</div>
</body>
</html>