< embed>与< object> [英] <embed> vs. <object>

查看:78
本文介绍了< embed>与< object>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想显示Adobe PDF查看器时,在HTML文件中哪个/最合适的标记是什么?

Which is the right/best tag to use in my HTML file when I want to display the Adobe PDF viewer?

现在我正在使用下面的代码,但是有一些怪异的副作用(例如,它似乎抢走了我已经设置到另一个<input>文本框的起始焦点;它似乎不能很好地发挥作用jQueryUI Resizeable类;等等)

Right now I'm using the code below, but there are weird side effects (e.g. it seems to steal the starting focus that I've set to another <input> text box; it doesn't seem to play real well with the jQueryUI Resizeable class; etc.)

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

我甚至可以使用<object>标签做同样的事情吗?使用一个标签相对于另一个标签是否有优点/缺点?

Could I even do the same thing with the <object> tag? Are there advantages/disadvantages to using one tag vs. the other?

推荐答案

对象vs.嵌入-为什么不是总是使用嵌入吗?

最重要的是:对象是好,嵌入是旧的.除了IE的PARAM标记外,如果浏览器不支持OBJECT的引荐插件,则OBJECT标记之间的任何内容都将被呈现,并且显然,无论是否呈现,都将请求HTTP请求内容.

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是当前在页面上嵌入内容的标准标签. embedobject之类的东西被包括在Netscape中(以及img) w3c 头脑.

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.

这是您包含带有object 的PDF的方式:

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>

如果您确实需要在几乎所有浏览器中显示内联PDF,因为较旧的浏览器可以理解embed而不是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>

此版本不验证.

这篇关于&lt; embed&gt;与&lt; object&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆