iframe 是否被视为“不良做法"? [英] Are iframes considered 'bad practice'?

查看:21
本文介绍了iframe 是否被视为“不良做法"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此期间的某个地方,我发现使用 iframe 是不好的做法".

Somewhere along the line I picked up the notion that using iframes is 'bad practice'.

这是真的吗?使用它们有什么优点/缺点?

Is this true? What are the pros/cons of using them?

推荐答案

与所有技术一样,它也有起有落.如果您使用 iframe 来绕过适当开发的站点,那么这当然是不好的做法.但是有时 iframe 是可以接受的.

As with all technologies, it has its ups and downs. If you are using an iframe to get around a properly developed site, then of course it is bad practice. However sometimes an iframe is acceptable.

iframe 的主要问题之一与书签和导航有关.如果您使用它来简单地将页面嵌入到您的内容中,我认为这很好.这就是 iframe 的用途.

One of the main problems with an iframe has to do with bookmarks and navigation. If you are using it to simply embed a page inside your content, I think that is fine. That is what an iframe is for.

然而,我也看到 iframe 被滥用.它不应被用作您网站的一个组成部分,而应作为网站内的一段内容.

However I've seen iframes abused as well. It should never be used as an integral part of your site, but as a piece of content within a site.

通常,如果您可以在没有 iframe 的情况下完成,那是更好的选择.我相信这里的其他人可能有更多信息或更具体的例子,这一切都归结为您试图解决的问题.

Usually, if you can do it without an iframe, that is a better option. I'm sure others here may have more information or more specific examples, it all comes down to the problem you are trying to solve.

话虽如此,如果您仅限于使用 HTML 并且无法访问 PHP 或 ASP.NET 等后端,有时 iframe 是您唯一的选择.

With that said, if you are limited to HTML and have no access to a backend like PHP or ASP.NET etc, sometimes an iframe is your only option.

这篇关于iframe 是否被视为“不良做法"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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