Pop up window scripts

Created: 12/26/2016 | Updated: 8/24/2018 | Status: Published

when using the trading platform as a widget in you content site you will have to add the next Tradesmarter code to your site in order to make the trading platfrom widget pop up windows to be open in the center of the screen (videos pop up, strategix pop up and more).

1. include this script before the end of your site 'body' tag:


<script>
jQuery(document).ready(function() {

    if (jQuery("#iframe").length > 0){
            var win = document.getElementById("iframe").contentWindow;

            jQuery(window).scroll(function() {

                var scrollMe = jQuery(window).scrollTop();
                console.log(scrollMe);
        if (scrollMe<1250) {
                win.postMessage(scrollMe, "*");
        }

            });
    }
   
    

var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";

// Listen to message from child window
eventer(messageEvent,function(e) {
    var key = e.message ? "message" : "data";
    var data = e[key];
     jQuery(window).scrollTop(20);
     console.log('parent received message!:  ',e.data);
},false);

         

    });


</script>

2. when calling the IFrame include this function:


onload="scrollTo(0,2);"

e.g:

<iframe onload="scrollTo(0,2);" src="http://trading.tradesmarter.com/" id="iframe" width="100%" height="1900" style="border: none;" scrolling="no"></iframe>