<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8" />
    <title>Add Button in Parent Window</title>
</head>

<body>
    <header>
    	<h3>Add button functionality from parent window</h3>
    	<button id="selectButton" class="greenButton" style="float: left;">Add</button>
    </header>
    <div id="iframe-wrapper">
    	<iframe id="iframe" width="100%" height="800" frameborder="0"></iframe>
		<script>
    		document.getElementsByTagName("iframe")[0].setAttribute("src", "/index.html?select=&origin=" + window.location.origin);
		</script>
    </div>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script>
        $("#selectButton").click(function() {
            $("iframe")[0].contentWindow.postMessage({
                "message":"select"
            }, window.location.origin);
        });

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

		eventer(messageEvent,function(e) {
			console.log('parent received message!:  ',e.data);
		},false);

    </script>
</body>
</html>
<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8" />
    <title>Add Button in Parent Window</title>
</head>

<body>
    <header>
    	<h3>Add button functionality from parent window</h3>
    	<button id="selectButton" class="greenButton" style="float: left;">Add</button>
    </header>
    <div id="iframe-wrapper">
    	<iframe id="iframe" width="100%" height="800" frameborder="0"></iframe>
		<script>
    		document.getElementsByTagName("iframe")[0].setAttribute("src", "../index.html?select=&origin=" + window.location.origin);
		</script>
    </div>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script>
        $("#selectButton").click(function() {
            $("iframe")[0].contentWindow.postMessage({
                "message":"select"
            }, window.location.origin);
        });

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

		eventer(messageEvent,function(e) {
			console.log('parent received message!:  ',e.data);
		},false);

    </script>
</body>
</html>
Add button demo should now work on github.io
Add button demo should now work on github.io
