この会話は、活動がないためロックされています。新しい投稿を作成してください。
この会話は、活動がないためロックされています。新しい投稿を作成してください。
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?
解決済! 解決策の投稿を見る。
表示
返信
いいね!の合計
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; }
表示
返信
いいね!の合計
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" ?
表示
返信
いいね!の合計
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.
表示
返信
いいね!の合計
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
表示
返信
いいね!の合計
This isn't related to my issue, as my bug is not related to Sightly scripting variables.
表示
返信
いいね!の合計
Can you share your code where you have declared the global variable ?
表示
返信
いいね!の合計
_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
表示
返信
いいね!の合計
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; }
表示
返信
いいね!の合計