≪Embed≫ Vs. ≪Object≫

embed vs. object

OBJECT vs. EMBED - why not always use embed?

Bottom line: OBJECT is Good, EMBED is Old. Beside's IE's PARAM tags, any content between OBJECT tags will get rendered if the browser doesn't support OBJECT's referred plugin, and apparently, the content gets http requested regardless if it gets rendered or not.

object is the current standard tag to embed something on a page. embed was included by Netscape (along img) before anything like object were on the w3c mind.

This is how you include a PDF with object:

<object data="data/test.pdf" type="application/pdf" width="300" height="200">
alt : <a href="data/test.pdf">test.pdf</a>
</object>

If you really need the inline PDF to show in almost every browser, as older browsers understand embed but not object, you'll need to do this:

<object data="abc.pdf" type="application/pdf">
<embed src="abc.pdf" type="application/pdf" />
</object>

This version does not validate.

Embedding HTML with object/embed introduces BODY and HTML tags

You have varied options to choose from, having iframes aside, you can:

  • use a javascript framework/lib which gives you the option to load the "sub-page" via Ajax, for example in jQuery, the .load() function.

  • use server-side language, i.e in PHP you can just use include, include_once, require, or require_once.

  • HTML Imports, <link rel="import" href="path-to-file/filename.html">, are the best and IMHO this should've been implemented long time ago, but the problem is it lacks wide browsers support, only Chrome and Opera currently, caniuse.com/imports

Use of Iframe or Object tag to embed web pages in another

The IFRAME element is part of the upcoming HTML5 standard. Also, HTML5 is developed by the major browser vendors out there (Mozilla, Opera, Safari, IE), that basically makes a guarantee that we will have an IFRAME element in the foreseeable future. Some of them have support for some HTML5 elements already, like AUDIO and VIDEO and some new JavaScript APIs.

It's also true that the OBJECT element is in the draft, but that's because IFRAME and OBJECT will have different purposes. IFRAMES are mainly designed for sandboxing web applications.

So, my advise is to use IFRAME instead of OBJECT.

Work with elements from embed or object tag

It will show up as a separate document, similar to an iframe. You can access it like this:

var svg = document.getElementById('graphics').contentDocument

Note that it is important to wait until the svg file is loaded; you might want to put your code in the object element’s onload event handler, like this:

<object data="graphics.svg" type="image/svg+xml" id="graphics" />
<script>
document.getElementById('graphics').addEventListener('load',function(){
var svg = document.getElementById('graphics').contentDocument
// do stuff, call functions, etc.
})
</script>

Differences between the HTML tags of embed, object, and video?

This might help: http://www.stoimen.com/blog/2009/02/22/html-object-and-embed-tags/

As for the video tag, WMVs wont always work because if you're on a Mac you would have to install a plugin

Inline SVG vs object embedded

It is possible to access the document inside an <object> or <embed> from the parent document. This is one of the (way too few) svg things ACID3 still tests.

Here's an example of how to modify an svg document from a script in the parent html document.



Related Topics



Leave a reply



Submit