Javascript Not Running in iframe Codeigniter 3 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Javascript Not Running in iframe Codeigniter 3 (/showthread.php?tid=72617) |
Javascript Not Running in iframe Codeigniter 3 - TemiU - 01-14-2019 I am updating a website from CodeIgniter 2 to CodeIgniter 3 (.1.9) We had an iframe embedded in several pages with javascript in the iframe to, among other things, put in a placeholder for telephone number and set the iframe height dynamically. This was working fine in our CodeIgniter 2 implementation, but the javascript does not seem to be running at all in the CodeIgniter 3 implementation. The page in which the iframe is embedded (page.php) has the following code: Code: <iframe id="iframe_form" src="<?php echo site_url('contact/request_consultation');?>" class="span3" scrolling="no" frameborder="0"></iframe> The javascript on the actual request_consultation page (which is in the iframe) is as follows: Code: <script type="text/javascript"> I tried moving the code into the page in which the iframe was embedded (page.php), but it did not work. It is entirely possible that I may not have referenced the iframe and/ or its elements correctly: Code: document.getElementById("iframe_form").(".phone").mask("(999) 999-9999",{placeholder:"_"}); I also tried giving the <div> on the parent page an id: Code: <div id="frame_span" > and then referencing the id from the request_consultation page, but that did not work, either. Code: $('#iframe_form', window.parent.document).height($('frame_span').height()); Any suggestions would be greatly appreciated. RE: Javascript Not Running in iframe Codeigniter 3 - InsiteFX - 01-14-2019 CodeIgniter has nothing to do with the JavaScript not running something else has to be wrong. The iframe is a pain in the neck and they recommend not to use them. Not sure but maybe this will help you. Using jQuery to Access iFrame Elements |