0

Problem calling window.addEventListener inside a script

asked 2016-05-18 18:26:14 +0800

Antoc gravatar image Antoc
21 4

I want to insert inside a zul file a non-zul div element that will include an external widget. I have added inside the html tag, in addition to the div element, also the AJAX script responsible for making server calls and populate the widget. This code works perfectly in a non ZK-environment. When it's added in a zul page however, it doesn't. It seems that the problem lies in the window element. What are the alternatives? Thanks in advance!

<html width="100%" height="415px">
                        <![CDATA[
                            <<script type = "text/javascript" !src="">
                            function async_load() {
                                        alert(3);
                                        var s = document.createElement('script');
                                        s.type = 'text/javascript';
                                        s.async = true;
                                        s.src = 'http://localhost:8080/Graph/javascript/widget-script.js';
                                        var x = document.getElementsByTagName('script')[0];
                                        x.parentNode.insertBefore(s, x);
                                    }

                              if(window.attachEvent){
                                  window.attachEvent('onload', async_load);
                              }else{
                                  window.addEventListener('load', async_load, false);
                               }

                            </script>

                            <div id="graphWidget" style="height: 100%; width: 100%">
                            </div>
                            ]]>
                        </html>
delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-05-18 18:26:14 +0800

Seen: 7 times

Last updated: May 18 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More