Welcome Guest, Not a member yet? Register   Sign In
Javascript Not Running in iframe Codeigniter 3

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:
<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:
<script type="text/javascript">


   $(".phone").mask("(999) 999-9999",{placeholder:"_"});

   $('#iframe_form', window.parent.document).height($('body').height());  


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:
document.getElementById("iframe_form").(".phone").mask("(999) 999-9999",{placeholder:"_"});

I also tried giving the 
<div> on the parent page an id: 
<div id="frame_span" >

 and then referencing the id from the request_consultation page, but that did not work, either.

$('#iframe_form', window.parent.document).height($('frame_span').height());

Any suggestions would be greatly appreciated.

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
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB