PDA

View Full Version : Ajax Page Fetcher Works in Fiewfox but not IE


trialone
01-21-2008, 10:03 AM
I am trying to use the Ajax Page Fetcher. The demo of the scriopt works in both FireFox and IE7. However, when I inserted the script into my own page, it perfectly in FireFox, but in IE7, it will not do anything.

Thank you in advance

Header
<head>
<title>1_main5</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--

#Container {
position:absolute;
left:0px;
top:0px;
width:766px;
height:780px;
margin-left: 15%;
margin-right: 15%;
}

#news-07_ {
position:absolute;
left:248px;
top:402px;
width:475px;
height:100px;
overflow: auto;
}

#news-08_ {
position:absolute;
left:248px;
top:442px;
width:475px;
height:1px;
}

#news-09_ {
position:absolute;
left:248px;
top:496px;
width:475px;
height:215px;
overflow: auto;
}
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript" src="ajaxpagefetcher.js">
/***********************************************
* Ajax Page Fetcher- by JavaScript Kit (www.javascriptkit.com)
* This notice must stay intact for usage
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more
***********************************************/
</script>
</head>

Calling of script in div

<div id="news-07_">
<table width="100%" border="0">
<div style="height:5px; overflow: auto">
<tr>
<td><a href="javascript:ajaxpagefetcher.load('news-09_', 'PressCenter/01072008.html', false)">07-JAN-2008</a></td>
<td>Announcement of Primary Filing</td>
</tr>
</table>

WA
01-21-2008, 06:02 PM
That's normal, actually. In IE, you'll need to view the webpage and run the script online in order to see it working. Offline the script won't run.

Smiats
01-22-2008, 06:27 PM
Simple...try this:


function SearchForFile(){
var request_;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_ = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
request_ = new XMLHttpRequest();
}
return request_;
}
var josh = SearchForFile();
function LoadPage(url){
josh.open('GET', url, true);
josh.onreadystatechange = handleInfo;
josh.send(null);
}
function handleInfo(){
var loading = 'Please Wait...';
if(josh.readyState == 1){
document.getElementById('PageViewing').innerHTML = loading;
}
if(josh.readyState == 2){
document.getElementById('PageViewing').innerHTML = loading;
}
if(josh.readyState == 3){
document.getElementById('PageViewing').innerHTML = loading;
}
if(josh.readyState == 4){
var response = josh.responseText;
document.getElementById('PageViewing').innerHTML = response;
}
}


The the link will simply be:

<a onClick="LoadPage('home.php')" style="cursor: pointer">Home Page</a>

Make the <div>:


<div id="PageViewing"></div>

A1ien51
01-22-2008, 08:19 PM
Your sample is really not the wise since you are not looking for the status code of 200 to make sure it was a sucess. If any other thing shows up, than that will appear in the window and will not be nice for the user.

The reason the orginal code did not work off the local file system is probably because the code is looking for 200. When it is run on the file system it returns a value of 0.

so the if statement should be if( [theXHRObject].status == 200 || [theXHRObject].status == 0 ) where [theXHRObject] is what ever variable they are using to hold the object.

Eric