In our javascript we create a global object that is used by many of our components. It seems to work fine when viewing the page without "editor.html" in the path; however when viewed with "editor.html" the variable is created and then removed entirely. So far I have not been able to figure out what is causing our global object to disappear; however the variable _g is present when "editor.html" is in the path and Granite is being used. Is there a setting in our site that is causing Touch UI to remove global objects created by our javascript code?
Solved! Go to Solution.
Views
Replies
Total Likes
I was able to figure out the root cause of your issue. When you open the page for editing with "editor.html" then AEM includes the page content inside an iframe.The iframe is contained inside the child window object of the main page. The parent window object includes all authoring controls like editing toolbar on the top and other elements required for authoring.
And when you access the page without the "editor.html" in the URL then there is no iframe and the page contents are part of the main window object. So it is an issue of scoping of the variable. You declared the global variable inside the iframe window and it will not be accessible outside the iframe window to the parent window object.
You need to declare your variable such a way that it is accessible to both child and parent windows-
//Example //Check if current window is not an iframe. if(self==top) { _varName = window._varName || {}; } else { _varName = window._varName || {}; window.parent._varName = _varName; }
Views
Replies
Total Likes
May be there is a name conflict when you view the page with "editor.html" in path. Have you tried renaming the variable and test with "editor.html" ?
Views
Replies
Total Likes
It doesn't seem like a naming conflict since the variable is removed completely. I tried creating other variables at the same point where this one is created and those disappear after continuing javascript execution as well.
Views
Replies
Total Likes
Hi
There is already an issue for Missing Scripting Variables.
Link:- https://docs.adobe.com/docs/en/aem/6-1/release-notes/known-issues.html ( Reference number "CQ-40324" )
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
This isn't related to my issue, as my bug is not related to Sightly scripting variables.
Views
Replies
Total Likes
Can you share your code where you have declared the global variable ?
Views
Replies
Total Likes
_varName = window._varName || {}
the object exists once it's declared, but it will go away afterward. this does not happen when viewing the normal page without editor.html
Views
Replies
Total Likes
I was able to figure out the root cause of your issue. When you open the page for editing with "editor.html" then AEM includes the page content inside an iframe.The iframe is contained inside the child window object of the main page. The parent window object includes all authoring controls like editing toolbar on the top and other elements required for authoring.
And when you access the page without the "editor.html" in the URL then there is no iframe and the page contents are part of the main window object. So it is an issue of scoping of the variable. You declared the global variable inside the iframe window and it will not be accessible outside the iframe window to the parent window object.
You need to declare your variable such a way that it is accessible to both child and parent windows-
//Example //Check if current window is not an iframe. if(self==top) { _varName = window._varName || {}; } else { _varName = window._varName || {}; window.parent._varName = _varName; }
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies