Need help for displaying HTML5 form elements into webbrowser in delphi

2.4k views Asked by At

I am working on adding new form elements from HTML5 like input type email, URL etc into webbrowser. I am able to save these controls into HTML file in a proper way. However, while loading that HTML file back into webbrowser, I am not getting that input type properly. I am getting input type as "text" irrespective of whatever type I am setting. Can anybody help me please.

1

There are 1 answers

1
Brian Cryer On

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.

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. 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.

If it doesn't behave as HTML5 in IE then you are missing something. 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.

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. 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.

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.