Kenet
10-09-2008, 12:58 AM
Ok, I have been thru about 10 scripts and this one is the closest to what I'm looking for... it doesn't strip out the javascript of the external files. However on thing that it doesn't do, and I need it to do is allow me to include the external page within a target <div>
Right now all it does is just include a file and I need to be able to call that external file dynamically and place it into a target <div>
Here's the code from http://www.javascriptkit.com/dhtmltutors/ajaxincludes.shtml
function HttpRequest(url){
var pageRequest = false //variable to hold ajax object
/*@cc_on
@if (@_jscript_version >= 5)
try {
pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try {
pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e2){
pageRequest = false
}
}
@end
@*/
if (!pageRequest && typeof XMLHttpRequest != 'undefined')
pageRequest = new XMLHttpRequest()
if (pageRequest){ //if pageRequest is not false
pageRequest.open('GET', url, false) //get page synchronously
pageRequest.send(null)
embedpage(pageRequest)
}
}
function embedpage(request){
//if viewing page offline or the document was successfully retrieved online (status code=2000)
if (window.location.href.indexOf("http")==-1 || request.status==200)
document.write(request.responseText)
}
HttpRequest("external.htm") //include "external.htm" onto current page
Basically I need to be able to call the code like this:
HttpRequest("external.htm, targetDiv")
Can anyone help me?
Right now all it does is just include a file and I need to be able to call that external file dynamically and place it into a target <div>
Here's the code from http://www.javascriptkit.com/dhtmltutors/ajaxincludes.shtml
function HttpRequest(url){
var pageRequest = false //variable to hold ajax object
/*@cc_on
@if (@_jscript_version >= 5)
try {
pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try {
pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e2){
pageRequest = false
}
}
@end
@*/
if (!pageRequest && typeof XMLHttpRequest != 'undefined')
pageRequest = new XMLHttpRequest()
if (pageRequest){ //if pageRequest is not false
pageRequest.open('GET', url, false) //get page synchronously
pageRequest.send(null)
embedpage(pageRequest)
}
}
function embedpage(request){
//if viewing page offline or the document was successfully retrieved online (status code=2000)
if (window.location.href.indexOf("http")==-1 || request.status==200)
document.write(request.responseText)
}
HttpRequest("external.htm") //include "external.htm" onto current page
Basically I need to be able to call the code like this:
HttpRequest("external.htm, targetDiv")
Can anyone help me?