如何在我的页面中调用Iframe JavaScript函数


How to call Iframe JavaScript function inside my page

我的页面旁边有Iframe,在下面的javascript中。

    function getTotSeats(){
    window.WebAppInterface.showToast(document.forms[0].txtSeat_no.value);
    return document.forms[0].txtSeat_no.value;
}

我想在我的页面中调用上面的javascipt函数。

我的页面是

<iframe name="select_frame" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" id="iframe_id" src="http://202.65.147.152:8080/tgtdc/etg/seatLayoutReservation.jsp?upDown=UP&toCityCode=100&serviceCode=34&totSeats=2&vehicle=HITECH%20-%20AC&toDate=31-08-2015&FR=F" width=100% style="z-index:10000" height="480" frameborder="0" scrolling="no" style="border:none;"></iframe>
<input type='button' name='save' value='SAVE' id="save_id" style="height:30px;width:100px;">
<script>
    $('#save_id').click(function() {
    var el = document.getElementById('iframe_id');
    var result=getIframeWindow(el).getTotSeats();
    alert(result);
});

但是我在页面中没有得到iframe函数值。我如何获得该值。你能请任何人帮我吗?

由于同源策略,您无法执行此操作。您可以使用postMessage查看跨窗口消息。

http://javascript.info/tutorial/cross-window-messaging-with-postmessage