Html 在 HTML5 中使用框架的任何方式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4846019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 06:25:11  来源:igfitidea点击:

Any way of using frames in HTML5?

htmlframes

提问by

For school I must make a website and it must use those crappy old damn fml frames. I've already complained about this to my teacher without any success :(

对于学校,我必须制作一个网站,它必须使用那些该死的破旧 fml 框架。我已经向我的老师抱怨过这件事,但没有任何成功:(

I want to use HTML5, but it seems that frames are deprecated. Am I really required to use XHTML or HTML 4? Is there some work-around that makes my pages validate HTML5 with use of frames?

我想使用 HTML5,但似乎不推荐使用框架。我真的需要使用 XHTML 或 HTML 4 吗?是否有一些解决方法可以使我的页面使用框架来验证 HTML5?

采纳答案by jmort253

Now, there are plenty of example of me answering questions with essays on why following validation rules are important. I've also said that sometimes you just have to be a rebel and break the rules, and document the reasons.

现在,有很多我用论文回答问题的例子,说明为什么遵循验证规则很重要。我也说过,有时你只需要成为一个反叛者,打破规则,并记录原因。

You can see in this example that framesets do work in HTML5 still. I had to download the code and add an HTML5 doctype at the top, however. But the frameset element was still recognized, and the desired result was achieved.

您可以在此示例中看到框架集在 HTML5 中仍然有效。但是,我必须下载代码并在顶部添加一个 HTML5 文档类型。但是frameset元素还是被识别出来了,达到了想要的效果。

Therefore, knowing that using framesets is completely absurd, and knowing that you have to use this as dictated by your professor/teacher, you could just deal with the single validation error in the W3C validator and use both the HTML5 video element as well as the deprecated frameset element.

因此,知道使用框架集是完全荒谬的,并且知道您必须按照教授/老师的指示使用它,您可以只处理 W3C 验证器中的单个验证错误并同时使用 HTML5 视频元素以及不推荐使用的框架集元素。

<!DOCTYPE html>
<html>
    <head>
    </head>
    <!-- frameset is deprecated in html5, but it still works. -->
    <frameset framespacing="0" rows="150,*" frameborder="0" noresize>
        <frame name="top" src="http://www.npscripts.com/framer/demo-top.html" target="top">
        <frame name="main" src="http://www.google.com" target="main">
    </frameset>
</html>

Keep in mind that if it's a project for school, it's most likely not going to be something that will be around in a year or two once the browser vendors remove frameset support for HTML5 completely. Just know that you are right and just do what your teacher/professor asks just to get the grade :)

请记住,如果这是一个学校项目,一旦浏览器供应商完全取消对 HTML5 的框架集支持,它很可能不会在一两年内出现。只要知道你是对的,只要按照老师/教授的要求去做就可以得到成绩:)

UPDATE:

更新:

The toplevel parent doc uses XHTML and the frame uses HTML5. The validator did not complain about the frameset being illegal, and it didn't complain about the video element.

顶级父文档使用 XHTML,框架使用 HTML5。验证器没有抱怨框架集是非法的,也没有抱怨视频元素。

index.php:

索引.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html>
    <head>
    </head>
    <frameset framespacing="0" rows="150,*" frameborder="0" noresize>
        <frame name="top" src="http://www.npscripts.com/framer/demo-top.html" target="top">
        <frame name="main" src="video.html" target="main">
    </frameset>
</html>

video.html:

视频.html

<!doctype html>
<html>
    <head>
    </head>
    <body>
        <div id="player-container">
            <div class="arrow"></div>
            <div class="player">

                <video id="vid1" width="480" height="267" 
                    poster="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb480.jpg"
                    durationHint="33" controls>
                    <source src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb_trailer_iphone.m4v" />

                    <source src="http://cdn.kaltura.org/apis/html5lib/kplayer-examples/media/bbb400p.ogv" />

                </video>

        </div>
    </body>
</html>

回答by Fordi

I know your class is over, but in professional coding, let this be a lesson:

我知道你的课已经结束了,但在专业编码中,让这成为一个教训:

  • "Deprecated" means "avoid use; it's going to be removed in the future"
  • Deprecated things still work - just don't expect support or future-proofing
  • If the requirement requires it, and you can't negotiate it away, just use the deprecated construct.
    • If you're really concerned, develop the alternative implementation on the side and keep it ready for the inevitable failure
    • Charge for the extra work now. By requesting a deprecated feature, they are asking you to double the work. You're going to see it again anyway, so might as well front-load it.
    • When the failure happens, let the interested party know that this was what you feared; that you prepared for it, but it'll take some time
    • Deploy your solution as quickly as you can (there will be bugs)
    • Gain rep for preventing excessive downtime.
  • “已弃用”的意思是“避免使用;将来会被删除”
  • 弃用的东西仍然有效 - 只是不要指望支持或面向未来
  • 如果需求需要它,并且您无法协商它,只需使用已弃用的构造。
    • 如果您真的很担心,请在旁边开发替代实现并为不可避免的失败做好准备
    • 现在为额外的工作收费。通过请求已弃用的功能,他们要求您将工作翻倍。无论如何你都会再次看到它,所以不妨先加载它。
    • 当失败发生时,让相关方知道这是你害怕的;你准备好了,但这需要一些时间
    • 尽快部署您的解决方案(会有错误)
    • 获得代表以防止过度停机。

回答by jerluc

Maybe some AJAX page content injection could be used as an alternative, though I still can't get around why your teacher would refuse to rid the website of frames.

也许可以使用一些 AJAX 页面内容注入作为替代方案,但我仍然无法理解为什么您的老师会拒绝删除网站的框架。

Additionally, is there any specific reason you personally want to us HTML5?

此外,您个人希望我们使用 HTML5 有什么具体原因吗?

But if not, I believe <iframe>s are still around.

但如果没有,我相信<iframe>s 仍然存在。

回答by You

You'll have to resort to XHTML or HTML 4.01 for this. Although iframeis still there in HTML5, its use is not recommended for embedding content meant for the user.

为此,您将不得不求助于 XHTML 或 HTML 4.01。尽管iframe在 HTML5 中仍然存在,但不建议将其用于嵌入面向用户的内容。

And be sure to tell your teacher that frames haven't been state-of-the-art since the late nineties. They have no place in any kind of education at all, except possibly for historical reasons.

并且一定要告诉你的老师,自 90 年代末以来,镜框就不是最先进的。他们在任何类型的教育中都没有立足之地,除非可能是出于历史原因。

回答by Keith

Frames were not deprecated in HTML5, but were deprecated in XHTML 1.1 Strict and 2.0, but remained in XHTML Transitional and returned in HTML5. Also hereis an interesting article on using CSS to mimic frames without frames. I just tested it in IE 8, FF 3, Opera 11, Safari 5, Chrome 8. I love frames, but they do have their problems, particularly with search engines, bookmarks and printing and with CSS you can create print or display only content. I'm hoping to upgrade Alex's XHTML/CSS frame without frames solution to HTML5/CSS3.

框架在 HTML5 中没有被弃用,但在 XHTML 1.1 Strict 和 2.0 中被弃用,但仍保留在 XHTML Transitional 中并在 HTML5 中返回。这里还有一篇关于使用 CSS 模拟没有框架的框架的有趣文章。我刚刚在 IE 8、FF 3、Opera 11、Safari 5、Chrome 8 中对其进行了测试。我喜欢框架,但它们确实存在问题,尤其是在搜索引擎、书签和打印方面,使用 CSS 可以创建打印或仅显示内容. 我希望将 Alex 的 XHTML/CSS 框架无框架解决方案升级到 HTML5/CSS3。

回答by user4668867

I have used frames at my continuing education commercial site for over 15 years. Frames allow the navigation frame to load material into the main frame using the target feature while leaving the navigator frame untouched. Furthermore, Perl scripts operate quite well from a frame form returning the output to the same frame. I love frames and will continue using them. CSS is far too complicated for practical use. I have had no problems using frames with HTML5 with IE, Safari, Chrome, or Firefox.

我在我的继续教育商业网站上使用框架已经超过 15 年了。框架允许导航框架使用目标特征将材料加载到主框架中,同时保持导航框架不变。此外,Perl 脚本从将输出返回到同一帧的帧形式运行得非常好。我喜欢相框并将继续使用它们。CSS 对于实际使用来说太复杂了。我在 IE、Safari、Chrome 或 Firefox 中使用带有 HTML5 的框架没有任何问题。