New Revised CSS Library Forums Web Tools
FAQs Awards Usage Terms Contact
Other Sections
Sweet Ads
Bookmark online:

IE5+ Opr7+

Document-in-document script

Author: Dynamic Drive

Description: Want to add the power of SSI to your site, but your web host doesn't support it? Use this script instead! It allows you to include a document inside another easily, simply by specifying the URL of the external document inside the "master" document. just like SSI. How does the script do that? With the help of a not-so-well-known DHTML feature in IE- scriplets. At it's bones, scriplets are a special kind of the <object> tag that supports a data" attribute. Put inside this attribute the file name of the external document, and the scriplet downloads and displays it as if it's part of the master document. By including the scriplet in multiple pages, a change to the target external document is instantly reflected on ALL of these pages. Ah, the power of DHTML!

Demo: The below example may not look like much, but it is, for one simple reason- it came from an external HTML file, dynamically downloaded and pasted onto this page by the scriplet!


Step 1: Simply add the following chunk of code wherever you wish to include another document inside the current. Remember to configure the width/height and data attributes to match the specifications of the external document.

Select All

One important note- scriplets are only supported by IE 4 and above. NS users will simply see nothing.

Just a few ideas on using scriplets. The external document to be downloaded by the scriplet should contain content that are the same across multiple webpages (such as the purple navigation buttons on the top of this page). By including the scriplet (instead of the actual content) on these pages, you can save yourself a lot of time when the time comes to editing this content- You simply do it once! There's no point in using a scriplet if you're only going to use it on one page. Another note- as mentioned earlier, scriplets are only supported by IE 4 and above. While this is definitely not good news in terms of cross browser compatibility, it may depend on your perspective. Since you know scriplets are only supported by IE 4 and above, the HTML document inside the scriplet can to designed to specifically target these users, without any fear of degradability with other browsers (since NS simply ignores scriplets). Be as creative as your imagination takes you- serve banners intended to be seen only by IE users, display content that utilizes all the whistles and bells of DHTML in IE, are just a few ideas you may want to sleep on...