cfmgrv4/app/Views/templates/front/iframe_form.php
2024-10-05 23:56:06 +09:00

29 lines
1.1 KiB
PHP

<!-- 처음 호출할때 사용법
$this->include('templates/' . $viewDatas['layout'] . '/actionform');
-->
<!-- 동적으로 ifram src 바꾸고싶을때
<span onClick="changeIframe_src('신규URL')" style="cursor:pointer;"></span>
-->
<div class="index_action_form">
<iframe id="index_iframe" src=" <?= current_url() . "/create" ?>" scrolling="no">
<p>사용 중인 브라우저는 iframe을 지원하지 않습니다.</p>
</iframe>
</div>
<script>
function resizeIframe() {
var iframe = document.getElementById('index_iframe');
iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
}
function changeIframe_src(target_url) {
var iframe = document.getElementById('index_iframe');
var newIframe = iframe.cloneNode();
newIframe.src = target_url;
iframe.parentNode.replaceChild(newIframe, iframe); // 기존 iframe을 새 iframe으로 교체
}
document.addEventListener('DOMContentLoaded', function() {
var iframe = document.getElementById('index_iframe');
iframe.onload = resizeIframe; // iframe이 로드된 후 높이를 조정
});
</script>