Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

JavaScript isn't executed #6

Description

@kornerc

I tried this example which should show an alert-dialog with the text test.
However, no dialog is displayed, neither with Firefox 65 nor with Chrome 72
Here is the code for this example

import dash_dangerously_set_inner_html
import dash
import dash_html_components as html

app = dash.Dash('')

app.scripts.config.serve_locally = True

app.layout = html.Div([
    dash_dangerously_set_inner_html.DangerouslySetInnerHTML('''
        <script type="text/javascript">alert('test')</script>
    '''),
])

if __name__ == '__main__':
    app.run_server(debug=True)

If an Iframe is used instead of dash_dangerously_set_inner_html, the dialog will appear.

import dash_dangerously_set_inner_html
import dash
import dash_html_components as html

app = dash.Dash('')

app.scripts.config.serve_locally = True

app.layout = html.Div([
    html.Iframe(srcDoc='''
        <script type="text/javascript">alert('test')</script>
    '''),
])

if __name__ == '__main__':
    app.run_server(debug=True)

Is it itentional that JavaScript isn't executed in dash_dangerously_set_inner_html or is it a bug?

Here are my package versions:

  • Python: Python 3.6.8
  • dash-dangerously-set-inner-html: 0.0.2
  • dash-core-components: 0.43.0
  • dash-html-components: 0.13.5
  • dash-renderer: 0.17.0
  • dash-table: 3.3.0
  • flask: 1.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions