My index html:
<html>
<head>
    <title>index</title>
    <script src="jquery.js"></script>
</head>
<body>
    <h1>Index</h1>
    <hr/>
    <iframe id="frame"></iframe>
    <hr/>
    <button id="btn">Click</button>
    <script>
    $(function(){
        window.api = {
            fun: function(){alert('index api')}
        };
        var frame = document.getElementById('frame');
        frame.src = 'frame.html';           
    });
    $('#btn').click(function(){
        $('#frame').contents().find('body').css('backgroundColor', 'red');
        $('#frame').contents().find('#btn').text('lol');
    });
    </script>
</body>
</html>
In the loaded frame.html the javascript can acces the api object via parent.api.
Is it possible to add an api object to frame.html window, so it is accessible via window.api there? (and not parent.api) (consider same origin and differnet origins)?
The above code does work (e.g. the #button changing the background and label), but I assume it's because all those documents are on my pc (same origin). Am I right?