Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'contentWindow' of undefined #21

Closed
alainib opened this issue Nov 17, 2015 · 0 comments
Closed

Cannot read property 'contentWindow' of undefined #21

alainib opened this issue Nov 17, 2015 · 0 comments

Comments

@alainib
Copy link

alainib commented Nov 17, 2015

Hello. i try to install this module on AngularJS v1.2.26.

I get an error, the iframe is null and i have no log 'Got iframe ready' on the console
index.html

<script type='text/javascript' src="resources/vendors/jquery/jquery.min.js"></script>
<script type='text/javascript' src="resources/vendors/bootstrap/bootstrap.min.js"></script>
<script type='text/javascript' src="resources/vendors/angular/angular.min.js"></script>
<script type='text/javascript' src='resources/vendors/angular/ng-xdLocalStorage.min.js'></script>

router.js

interfaceApp.run(function (xdLocalStorage) {
    xdLocalStorage.init({
        iframeUrl:'http://wp5test.XXXnat.org/basket/',
        initCallback: function () {
            console.log('Got iframe ready');
            xdLocalStorage.setItem('check', 'no callback');
        }
    }).then(function () {
        // an option function to be called once the iframe was loaded and ready for action
        console.log('Got iframe ready');
    });

});

I get the following error :

Error: f is undefined
c@http://localhost:63342/trunk/resources/vendors/angular/ng-xdLocalStorage.min.js:1:473
window.xdLocalStorage</<.setItem@http://localhost:63342/trunk/resources/vendors/angular/ng-xdLocalStorage.min.js:1:1427
d/<@http://localhost:63342/trunk/resources/vendors/angular/ng-xdLocalStorage.min.js:1:1987
Ae/e/l.promise.then/F@http://localhost:63342/trunk/resources/vendors/angular/angular.min.js:100:178
Ae/f/<.then/<@http://localhost:63342/trunk/resources/vendors/angular/angular.min.js:101:350
Zd/this.$get</k.prototype.$eval@http://localhost:63342/trunk/resources/vendors/angular/angular.min.js:112:64
Zd/this.$get</k.prototype.$digest@http://localhost:63342/trunk/resources/vendors/angular/angular.min.js:109:160
Zd/this.$get</k.prototype.$apply@http://localhost:63342/trunk/resources/vendors/angular/angular.min.js:112:396
lc[c]</<.compile/</<@http://localhost:63342/trunk/resources/vendors/angular/angular.min.js:194:224
m.event.dispatch@http://localhost:63342/trunk/resources/vendors/jquery/jquery.min.js:3:8384
m.event.add/r.handle@http://localhost:63342/trunk/resources/vendors/jquery/jquery.min.js:3:5122

what i'm doing wrong ?
Thanks


UPDATE 1

I found that in the project there is another iframe using the approximatly the same url but without the angular way :

<iframe id="XXXnatMenu" class="XXXnat-menu" seamless="seamless" scrolling="no" src="http://wp5prod.XXXnat.org/menu/"></iframe>
    <script type="text/javascript">
    window.onload = function() {
 var frame = document.getElementById("XXXnatMenu").contentWindow;
 frame.postMessage({type: "user", username: "Julien", userProfile: "No"}, "http://wp5prod.XXXnat.org/menu/");
 };

 function receiveMessage(event) { 
 if(event.origin == "http://wp5prod.XXXnat.org") {
 if(event.data.type == "redirect") {
     top.window.location.replace(event.data.url);
 }
 }
 }


 window.addEventListener("message", receiveMessage, false);*/
    </script>

If i remove this part the angular local storage work.


UPDATE 2
It works now. i change the windows.onload by a document.onload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants