0

How can i add javascript code for the onload event for the iframe. I need my code to appear not at the header, but directly inside the iframe element.

`<script type="text/javascript">
$(document).ready(function(){
 $('#innerFrame').iframeHeight({
    debugMode: true,
    watcher: true
    });
});

</script>`<--!This is the script i want to add-->
Not a bug
  • 4,286
  • 2
  • 40
  • 80
Lusia
  • 23
  • 1
  • possible duplicate of [JQuery and frames - $(document).ready doesn't work](http://stackoverflow.com/questions/221192/jquery-and-frames-document-ready-doesnt-work) – rorypicko Jan 14 '14 at 12:50
  • Welcome to SO...refer [this document](http://stackoverflow.com/questions/how-to-ask) please before asking next question. and try to provide it in [SSCCE](http://sscce.org/) format. – Not a bug Jan 14 '14 at 13:10

1 Answers1

0

Using following code:

$("#frmae_id").ready(function() { 
  // Write your frame onload code here
}

This kind of question asked before here.

According your update of question it is not possible because same orgin policy. Read about here it is already asked before.

Community
  • 1
  • 1
Khamidulla
  • 2,927
  • 6
  • 35
  • 59
  • Thank you, but I think i meant probably different. I am new with jquery and the thing which i was asking is that i dont't have the header and the body (cause it is automatically generated form the environment), the only access i have is to the element, which appears on the page is the iframe. for this iframe i have to call the fuction, which i wrote, what aould be the best way to call it. – Lusia Jan 14 '14 at 12:59
  • Your there is no .iframeHeight() function in jquery unless you use some plugin code. Another thing try to state your question more clear way. Can you put some step by step actions which you want to do. – Khamidulla Jan 14 '14 at 13:06
  • Yes, exactly, this is the plugin, which was implemented into into the environment, this environment generates the .html file, where gives as result the only access for the element. and my question is it possible actually to call smth like onload event for this element, where i can place the jquery. The environment in cause of protection security will not let my write the and so on. Therefore i need to implement it inside the element somehow. The question is it it actually possible? – Lusia Jan 14 '14 at 13:11
  • See update part. :( Sorry it is not possible. Only what you can do is bind events to iframe. – Khamidulla Jan 14 '14 at 13:19