mendixlabs / IFrame

Embed another HTML document in your web application
https://appstore.home.mendix.com/link/app/21/Mendix/IFrame
Apache License 2.0
3 stars 13 forks source link

Problem with closing page on Mx 6.4.1 #2

Closed JelleDekker closed 8 years ago

JelleDekker commented 8 years ago

Using the iFrame widget on a page in Mx 6.4.1 I have encountered the following UI issue:

Furthermore:

Update:

JelteMX commented 8 years ago

Jelle, could you send a testproject regarding this issue to community [at] mendix.com? We haven't encountered these issues yet, so we'd like to troubleshoot it.

JelleDekker commented 8 years ago

I'll send the test project, For now you can already find it at https://iframewidgetbug.mxapps.io/index.html?profile=desktop

  1. Select first item in datagrid (which links to Mendix.com)
  2. Click "Edit"
  3. Click "Action"
  4. Click "Cancel" >> iframe disappears, page stays open
  5. Click "Cancel" again >> page closes
  6. Click "Action" again >> nothing happens
  7. Click "Action" a few more times
  8. Click "Cancel" >> the page with the Iframe opens again
  9. Click "Cancel" again on the page with iFrame that opened, you'll see that there are more of these opened now (depending on how active you were at step 7)
JelleDekker commented 8 years ago

Second scenario:

  1. Select first item in datagrid (which links to Mendix.com)
  2. Click "Edit"
  3. Click "Action"
  4. Click "Cancel" twice to close page with iFrame
  5. Click "Cancel" again to close the edit page
  6. Click "New" >> the page doesn't open, however from the autonumber you can see that the new objects have been created

Third scenario:

  1. Select second item in datagrid (which links to Google.nl)
  2. Click "Edit"
  3. Click "Action"
  4. Click "Cancel" >> all works fine when the iFrame was not able to load it's content
edwinmp commented 8 years ago

Hi,

Investigated this problem and in my test project, it's originating from two Mendix App Cloud widgets: Mendix App Switcher and Mendix Profile Menu. These two widgets appear to be conflicting with the IFrame widget.

The code below from the Profile Menu & App Switcher widgets raise a multipleDefine(…) dojo error because it appends the same scripts multiple times.

           ioScript.get({
                url: url + 'mendixtoolbar/js/buttonservices.js?PP_6.20',
                error: dojo.hitch(this, function (e) {
                    console && console.log('Mendix AppSwitcher/ProfileMenu could not load external script: ', e);
                })
            });

On cancel, another error is triggered, originating from the same buttonservice script that the two widgets are appending:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://home.mendix.com') does not match the recipient window's origin ('http://localhost:8080').

This is because the AppSwitcher and ProfileMenu widgets, which generate iframes of their own, are attempting to access an external source running over https yet their origin is not secure (http).

Well, this was all on the assumption that you have these two widgets active in your project too. If so, then I suggest you decide how much you need them in there and consider removing them.

JelleDekker commented 8 years ago

I don't have those widgets in the project where this error originated I'm afraid. Also in the project where I first noticed this, the browser console doesn't show any errors.

Edit: I just updated the example project to resemble the real one more. Removed the two widgets you mentioned and instead added the FormatString widget, which we do use.

JelteMX commented 8 years ago

I checked the testproject you provided (thanks by the way 😄 ) and found the issue. The reason for this issue is actually that when you update the context object (actually an update is triggered as well when you press Cancel), the url was reloaded. So I changed some of the code, in which that doesn't happen anymore.

Please note (this will be noted in the documentation as well) that some websites do fail to load in an iframe due to restrictions, but that it's pretty hard to determine when this happens. For a website like google.nl, it is blocked in the browser which is impossible circumvent. If for example I load http://nu.nl these problems do not arise.

I'll have a fix for you to test

JelteMX commented 8 years ago

Please test this version and provide me with some feedback whether or not this issue is fixed for you

edwinmp commented 8 years ago

The CKEditorForMendix would be an excellent alternative. it has a pretty good iFrame plugin with similar options and a few extra.

JelleDekker commented 8 years ago

@JelteMX The solution seems to work. However in my original application the problem still occurred, I managed to fix it there by removing a "refresh" in the action that processed the users input in the screen.

I tried to reproduce the situation which still gave the problems also in the test project, but there everything goes fine when I do.

JelteMX commented 8 years ago

Great! I'll create an update for the AppStore

JelteMX commented 8 years ago

Fixed in 3.1.1