简体   繁体   English

需要帮助在Delphi中将HTML5表单元素显示到Webbrowser中

[英]Need help for displaying HTML5 form elements into webbrowser in delphi

I am working on adding new form elements from HTML5 like input type email, URL etc into webbrowser . 我正在努力将HTML5中的新表单元素(例如输入类型的电子邮件,URL等)添加到webbrowser中 I am able to save these controls into HTML file in a proper way. 我能够以适当的方式将这些控件保存到HTML文件中。 However, while loading that HTML file back into webbrowser, I am not getting that input type properly. 但是,在将该HTML文件加载回webbrowser时,我没有正确获取该输入类型。 I am getting input type as "text" irrespective of whatever type I am setting. 无论我设置什么类型,我都将输入类型设为“文本”。 Can anybody help me please. 有人可以帮我吗。

It is worth pointing out that I have been conversing with Manasee about this and have seen the code, so this answer is aimed more at anyone with a similar problem. 值得指出的是,我已经与Manasee进行了交谈并看到了代码,因此,此答案更多地针对有类似问题的任何人。

Assuming that you have the HTML5 file saved locally, then start by making sure that when loaded by Internet Explorer that the HTML5 elements behave as expected. 假设您已将HTML5文件保存在本地,然后首先确保在Internet Explorer加载HTML5元素时,其行为符合预期。 Internet Explorer (and thus TWebBrowser) has a tendency to want to use a compatible view so may render as IE8 or earlier and this will stop HTML5 elements from working. Internet Explorer(以及TWebBrowser)倾向于使用兼容的视图,因此可能呈现为IE8或更早版本,这将使HTML5元素停止工作。

If it doesn't behave as HTML5 in IE then you are missing something. 如果它在IE中不能像HTML5那样运行,则说明您丢失了某些内容。 I suggest having both: 我建议同时拥有:

<!DOCTYPE html>

as the first line of the file and: 作为文件的第一行,并:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

as the first line in the HEAD. 作为HEAD中的第一行。

If IE renders your file as HTML5 but your embedded TWebBrowser doesn't, then this indicates an issue with how the file is being loaded. 如果IE将您的文件渲染为HTML5,但嵌入式TWebBrowser却没有,则表明文件的加载方式存在问题。 There are a number of ways that HTML can be loaded or injected into the browser, some of these will leave TWebBrowser emulating an earlier version. 可以通过多种方式将HTML加载或注入到浏览器中,其中一些方式会使TWebBrowser模仿早期版本。

So try simply: 因此,只需尝试:

webbrowser.Navigate('file://C:/myFile.html');

One final point. 最后一点。 Don't try this on XP - it doesn't support a version of IE that recognises HTML5 so neither will TWebBrowser. 不要在XP上尝试此操作-它不支持可识别HTML5的IE版本,因此TWebBrowser也不支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM