Issue #1123Opened May 21, 2018by alfaalex810 reactions

[QUESTION] Onload event inside template

Question

Hi! I have a problem with some templates. This template has some scripts running after the page is loaded. When this templates is loaded by GrapeJs, the scripts do not starting because browser not detect the ending of load.

It's possibile to load templete in a classic iframe (not injected)?

For example: <iframe src="http://myexamplepages.com" frameborder="0" style="overflow:hidden;height:100%;width:100%" height="100%" width="100%"></iframe>

It is possible to use this solution or you can suggest other one.

Thanks.

Answers (3)

artfMay 24, 20180 reactions

Have you tried with this?

const editor = grapesjs.init({
	...
	allowScripts: 1,
});
alfaalex81May 24, 20180 reactions
Code SnippetTEXT
Sure, other scripts with "allowScripts" parameter work fine, but scripts inside "on load event" don't.

I inject the code in this way:

`       var newComps = editor.DomComponents;
        $.get('http://myexamplepages.com', function (e) {
            newComps.setComponents(e);
        });
        window.editor.setComponents(newComps);
`

Thanks.
artfMay 26, 20180 reactions

@alfaalex81 can you provide a live demo of the issue?

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.