home forums resources search newsjoinmembers: 6954
Sections PHP Flash Java Ruby Windows Linux
Hiveminds's picture

Hiveminds | Thu, 2008-07-17 17:26  tags: , , ,

Just about every one has seen the object tag when embedding flash animation into a HTML page. Did you know that the tag can be used to include other types of objects as well? For example, you can use the tag like an include() function to display files within the borders defined by the tag. You could use this to include separate header and footer files even though you do not have server-side include support.

This code shows how to use the tag to accomplish including a "footer" file in a Web-page. Note the use of the 'data' attribute to identify the html page file that is to be displayed inside the main page (archive.html).

<html><head></head><body>  
 <object data="archive.html" type="text/html"></object>
 <p>back up content</p>
 </body></html>

The included HTML file, which acts as the "include" file,should have

<style type="text/css"> body { overflow:visible; border:0px; } </style>

inside its header to avoid a black border.

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
 <head>
  <title></title>
  <meta name="robots" content="noindex,nofollow" />
  <meta name="googlebot" content="noarchive" />
  <meta http-equiv="content-style-type" content="text/css" />
  <style type="text/css">
    body {overflow:visible; border:0px; background-color:#d4dde4;
         }
  </style>
 </head>
 <body>
  <!-- archive module: -->
  <table>
   <tr>
    <td align="left">
     <h6><a href="../contact.php" title="Contact owner">Contact</a> | <a href="../about.php" title="About This  Site">About</a> | </h6>
    </td>
    <td align="right">
     <table cellspacing="0">
      <tr>
       <td>
        <h6><a href="" title="Legal: Copyright"> 2006</a></h6>
       </td>
       <td>
        <h6><a href="../" title="Organization">Programmabilities.com</a>. All rights reserved. <a href="http://creativecommons.org/licenses/by/2.5/legalcode" title="Legal: Terms of Use" >Terms of Use</a> | <a href="http://creativecommons.org/licenses/by/2.5/legalcode" title="Legal: Privacy Policy" >Privacy Policy</a></h6>
       </td>
      </tr>
     </table>
    </td>
   </tr>
  </table>
  <!-- END archive module. -->
 </body>
</html>

If you want to test this you can just place the code on a HTML page and surf to it in your browser. Since the code is run but you have not yet placed the file that is to be included you will be greeted by a:

Not Found

The requested URL /hiveminds.co.uk/archive.html was not found on this server.

IE6 and IE7 behave differently and need to have the classid for the object present. This is the same as when flash is embedded. You can also back up the content so that you do not get a file not found.


<!--[if IE]>
<object classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" data="archive.html">
<p>backup content</p>
</object>
<![endif]-->


Happy Publishing!

Hiveminds's picture
This article brought to you by the Hiveminds Magazine - Staff. Contact us if you want to post an article or announcement anonymously
Thoughtbox - So what did you think?



a Visitor posted on: Thu, 2008-07-17 15:46.

This technique looks interesting, but what about browser support, google indexing, and is it supported by the W3? Have you done any tests?

Thanks for the article though, great idea. I will have to give those tests a little research and see what I come up with.

Carl posted on: Thu, 2008-07-17 18:18.

This was not something that I use or would ever use because of the way IE works with objects. I just remembered that I had done it once a while ago and decide to post it here because I could not find my notes on the subject.

If anyone comes up with anything useful for this please let me know.

a Visitor posted on: Fri, 2008-07-18 16:29.

Very interesting use of the object tag

but not quite sure I would us it often :)

 

CMS Comparison Matrix

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.