<嵌入>与<对象> [英] <embed> vs. <object>

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

问题描述

当我想显示 Adob​​e PDF 查看器时,在我的 HTML 文件中使用哪个标签最合适/最好?

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

现在我正在使用下面的代码,但是有一些奇怪的副作用(例如,它似乎窃取了我设置到另一个 文本框的起始焦点;它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" />

我能用 标签做同样的事情吗?使用一种标签与另一种标签相比有什么优点/缺点吗?

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

推荐答案

OBJECT vs. EMBED - 为什么不总是使用嵌入?

底线:OBJECT 是好的,EMBED 是旧的.除了 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 是当前用于在页面上嵌入某些内容的标准标记.embed 已被 Netscape 收录(与 img 一起)object 之类的东西出现在 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;嵌入&gt;与&lt;对象&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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