- 301 redirects using PHP
- Content Creation
- CSS Layouts
- Ecommerce Essentials
- FTP Tutorials
- IE Bug - Creeping Text
- Javascript Image Transitions
- Javascript Slideshow
- Javascript Swap on Hover
- Javascript Switch
- SEO
- Useful Web Resources
- Web Directories
- Inserting External HTML
- Setting Up Email
- Zen Cart buttons
Different methods of inserting external HTML in to a document
Here are a few examples for inserting an external html file into a document. This article is only a stub until I can develop it further.
Inserting via javascript (jquery):
Very easy, especially if you are already using the jquery library. More information of how this method works can be found on the jquery site. This method uses GET/POST methods and will NOT allow you to insert content from an external domain. Still searching for a method that allows cross-domain content that also works in most browsers.
In the document head:
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
$(function () {
$("#targetDiv").load("data.html");
});
});
</script>
and in the body:
<div id="targetDiv"></div>
Inserting via OBJECT tag:
Similar to an Iframe. Spotty support across different browsers such as you can NOT control the border property in IE so you get the ugly scrollbar even if your content does not exceed the size of the object. Conditional is required for IE since it needs the classid attribute. More information about the object tag can be found here and
<!--[if IE]>
<object
classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13"
data="data.html"
style="height:400px;width:400px;">
<p>Data was not fetched</p>
</object>
<![endif]-->
<!--[if !IE]> <-->
<object type="text/html"
height="400px" width="400px"
border="0" data="data.html"
style="height:400px;width:400px;border:0; ">
<p>Data was not fetched</p>
</object>
<!--> <![endif]-->
Inserting via iframe:
Supported in most browsers but is not supported with strict DOCTYPEs. Access to external domains available per testing in IE7 and FF3.
<h2>Yahoo Iframe</h2>
<iframe src="http://www.yahoo.com"
style="height:400px;border:0;">
No iframe support</iframe>
<p>End Yahoo</p>
<h2>Local data.html</h2>
<iframe src="data.html"
style="height:400px;border:0;">
No iframe support</iframe>
<p>End local</p>
embedding external html
Post new comment