我的页面中有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函数值。我如何获得该值。可以请任何人帮助我。
答案 0 :(得分:0)
由于同源策略,您无法执行此操作。您可以使用postMessage查看跨窗口消息传递。
http://javascript.info/tutorial/cross-window-messaging-with-postmessage