Jump to content

Html File In Div Block


sairfan1
 Share

Recommended Posts

Well, depends how you define "outside", I suppose. If the page to be included is from the same domain, just using the XMLHttpRequest object would suffice, however if he means from another domain, then yes, you can't do it with just JavaScript but need some form of proxy on your host to fetch the page for you.http://www.w3schools.com/ajax/

Link to comment
Share on other sites

Well, depends how you define "outside", I suppose. If the page to be included is from the same domain, just using the XMLHttpRequest object would suffice, however if he means from another domain, then yes, you can't do it with just JavaScript but need some form of proxy on your host to fetch the page for you.
I think that most of the time it would be same domain/site, guess I would need to find an example of this XMLHttpRequest object for including files like iframes.
Link to comment
Share on other sites

guess I would need to find an example of this XMLHttpRequest object for including files like iframes.
did you check the link he posted?
Link to comment
Share on other sites

did you check the link he posted?
Yes, you talking about this example?
<html><head><script type="text/javascript">function loadXMLDoc(url){if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.open("GET",url,false);xmlhttp.send(null);document.getElementById('test').innerHTML=xmlhttp.responseText;}</script></head><body><div id="test"><h2>Click to let AJAX change this text</h2></div><button type="button" onclick="loadXMLDoc('test1.txt')">Click Me</button><button type="button" onclick="loadXMLDoc('test2.txt')">Click Me</button></body></html>

I feel i've changed the topic posted from irfan ullahHe's example would be something like this;

<!--#include virtual="somefile.inc"--><!--#include file ="somefile.inc"--><?php require("file_to_include.php"); ?><script type="text/javascript" src="path to file/include-file.js"></script>SSI (server side includes)<!--#include virtual="path to file/include-file.html" -->

Edited by student101
Link to comment
Share on other sites

I don't understand what you are trying to say. JavaScript's XMLHttpRequest object allows you to make asynchronous HTTP requests to the current domain and manipulate the results, for example by inserting the response text into an existing part in the page, like a server-side include would. I don't see how iframes come into it. You don't need to use any form of server-side language with AJAX, either, as your example seems to imply.http://www.google.com.au/search?q=include+page+ajax

Link to comment
Share on other sites

I don't understand what you are trying to say. JavaScript's XMLHttpRequest object allows you to make asynchronous HTTP requests to the current domain and manipulate the results, for example by inserting the response text into an existing part in the page, like a server-side include would. I don't see how iframes come into it. You don't need to use any form of server-side language with AJAX, either, as your example seems to imply.
My question was answered looking at the ajax url posted by you; (posted the code, to make it clearer for me), same as including files like iframes except more code and better, If iframes are fround upon why do CMS's like FCKeditor still use them?Edit;I am a serious FCKeditor fan! Edited by student101
Link to comment
Share on other sites

WYSIWYG editors such as FCKeditor work by using iframes to display the generated HTML code. While you maybe could (somehow) use AJAX for this*, you will then run into problems with conflicting CSS styles, superfluous tags, etc.* there is actually a specific part of JavaScript for making WYSIWYG editors with, which includes commands like execCommand() and properties like contentEditable, but they are not perfectly supported yet. So until then, iframes it is.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...