Refuse to work at all on browsers that do not support <iframe srcdoc>

This commit is contained in:
Kovid Goyal 2017-05-19 09:51:17 +05:30
parent 97e337784d
commit 133a073ef7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 1 deletions

View File

@ -125,6 +125,12 @@ def do_update_interface_data():
def main():
if document.createElement('iframe').srcdoc is undefined:
document.body.innerHTML = '<p style="margin:1.5em; max-width: 40em">' + _(
'You are using a browser that does not have the iframe srcdoc attribute.'
' This is not supported. Use a better browser such as <b>Google Chrome</b> or <b>Mozilla'
' Firefox</b>, instead.')
return
interface_data = get_interface_data()
if interface_data.is_default or not interface_data.library_map:
load_interface_data()

View File

@ -231,7 +231,9 @@ def sandboxed_html(html, style, sandbox):
html = html or ''
css = 'html, body { margin: 0; padding: 0; font-family: __FONT__ } p:first-child { margin-top: 0; padding-top: 0; -webkit-margin-before: 0 }'.replace('__FONT__', get_font_family())
css += style or ''
ans.srcdoc = f'<html><head><style>{css}</style></head><body>{html}</body></html>'
final_html = f'<!DOCTYPE html><html><head><style>{css}</style></head><body>{html}</body></html>'
# Microsoft Edge does not support srcdoc not does it work using a data URI.
ans.srcdoc = final_html
return ans
if __name__ is '__main__':