AnonymousX Posted December 5, 2006 Share Posted December 5, 2006 After reading the problems with Firefox post, I thought this to be a fitting name :)Basically, I couldn't find a way to enable Server Side Includes on our web server, so I found a javascript include to use. It's the Ajax include script if you are familiar with it. It says that the compatibility for it is IE5+ but when I open it in IE7 the included content won't work. I tried opening the included content (navigation bar) in IE7 and it worked fine by itself, and the main HTML file opens and works fine in IE7, so the problem arises somewhere in the include. The code concerning the include is as follows. <html><head><script type="text/javascript">/************************************************ Ajax Includes script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)* This notice MUST stay intact for legal use* Visit Dynamic Drive at [url=http://www.dynamicdrive.com/]http://www.dynamicdrive.com/[/url] for full source code***********************************************///To include a page, invoke ajaxinclude("afile.htm") in the BODY of page//Included file MUST be from the same domain as the page displaying it.var rootdomain="http://"+window.location.hostnamefunction ajaxinclude(url) {var page_request = falseif (window.XMLHttpRequest) // if Mozilla, Safari etcpage_request = new XMLHttpRequest()else if (window.ActiveXObject){ // if IEtry {page_request = new ActiveXObject("Msxml2.XMLHTTP")} catch (e){try{page_request = new ActiveXObject("Microsoft.XMLHTTP")}catch (e){}}}elsereturn falsepage_request.open('GET', url, false) //get page synchronously page_request.send(null)writecontent(page_request)}function writecontent(page_request){if (window.location.href.indexOf("http")==-1 || page_request.status==200)document.write(page_request.responseText)}</script><title></title></head><body> <script type="text/javascript">ajaxinclude("hs_links.html")</script></body></html> I'm also having troubles including a second item, an announcement bar. When I include that, it throws the script for the drop menu out of sync. But that's the least of my concerns right now. Thanks in advance. Link to comment Share on other sites More sharing options...
AnonymousX Posted December 6, 2006 Author Share Posted December 6, 2006 Sorry to double post but does anybody have a solution to this problem. Link to comment Share on other sites More sharing options...
jesh Posted December 6, 2006 Share Posted December 6, 2006 function ajaxinclude(url) {var page_request = false...page_request.open('GET', url, false) //get page synchronously page_request.send(null)writecontent(page_request)}function writecontent(page_request){if (window.location.href.indexOf("http")==-1 || page_request.status==200)document.write(page_request.responseText)} I've never used AJAX like what you have so I can't say if there's something in this code that fails. However, I've always had great luck using it like this:var page_request;function ajaxinclude(url){//var page_request = false; // moved this to a global....page_request.onreadystatechange = handleRequest;page_request.open('GET', url, false); //get page synchronously page_request.send(""); // note "" rather than null}function handleRequest(){ if(page_request.readyState == 4) { if(page_request.status == 200) { document.write(page_request.responseText); } }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now