클릭 이벤트를 사용하여 변수를 iframe에서 수신하려고 시도하면 (크로스 도메인) 부모에게 메시지가 전송됩니다. 받는 메시지 정보로 iframe의 높이를 변경하고 싶습니다. 여러 번 시도했지만 아무 것도 효과가 없었습니다.click 이벤트가있는 iframe에서 parent로 메시지 보내기
<script type="text/javascript">
jQuery(function($){
$(window).bind('message', function(event){
var height,
oEvent = event.originalEvent;
if (oEvent.origin != 'http://some-domain-name.com') {
return false;
} else {
$('#autoIframe').css('height' , height + 'px');}
});
});
</script>
을 그리고 이것은 iframe 대응의 도메인을 사용하여 무엇을 임 :
이
스크립트는 부모에 사용<script>
if (top != self) {
jQuery(function($) {
if (!!window.postMessage) {
$('#bestellen_oben').click(function(){
parent.postMessage('5000', '*');
});
}
})
}
</script>
누군가가 생각이 있습니까?
감사합니다.
그것은 로컬 호스트에 나를 위해 작동 postMessage 두 번째 매개 변수를'http : // localhost'로 설정하면 – jcubic