I want to load content of my page inside a div element using this function:
function loadmypage(DIV, pageURL)
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(DIV).innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", pageURL ,true);
xmlhttp.send();
}
However when I click on a link inside the ‘frame’ itself, the function doesn’t work. I guess the reason for that that the target element is in different page from the loaded page
itself.
So my question is: Is there any way to make div element behave like an iframe in loading the whole page inside the frame itself?
PS: I am not allowed to use iFrame for security reasons neither jQuery for efficiency reasons.
links in the main page load the target normally, the problem appears when i click at any link inside these pages.
<div id="nav" class="mmenu">
<ul type="none">
<li><a href= "javascript:loadmypage('viewMessages.php')">Messages</a></li>
<li><a href= "javascript:loadmypage('userHomepage.php')">My Conferences</a></li>
<li><a href= "javascript:loadmypage('availableConferences.php')">Conferences</a></li>
<li><a href= "javascript:loadmypage('incomingRequests.php')">Requests</a></li>
<li><a href= #>News</a></li>
<li><a href= #>Options</a></li>
</ul>
</div>
</fieldset>
<div id="collabsoft" class="collabsoft">
Your links don’t work because you’re missing your div argument. Notice your function:
The first argument is DIV, and you’re passing the pageURL only.