javascript - Calling /../file.js function from inline declared html js gives - ReferenceError: function is not defined -


im trying call function declared within /js/file.js - inline js <script> tag'.

what happens is:

  1. from /js/file.js call function triggeredbyjsfile() declared in inline <script> tag'
  2. then inline <script> tag' end doing callback function within /js/file.js - imagesloaded()

im getting error each time try callback /js/file.js function: "referenceerror: imagesloaded not defined"

my setup following:

<html> <head>   <!-- js file containing function want call -->   <script src="js/file.js"></script> </head>  <body>    <div id="content">....</div>       <script> function triggeredbyjsfile() {   //does lot of stuff ,   initiatesomething(); }  function initiatesomething() { //reference js file       imagesloaded(); }     </script> </body> </html> 

my /js/file.js

$(document).ready(function () {  triggeredbyjsfile();      function imagesloaded() {         alert("images loaded");     }  }); 

error firebug console shows me

referenceerror: imagesloaded not defined [break on error]     imagesloaded(); 

figured able long load .js file before reference / function call @ bottom?

imagesloaded defined in scope of anonymous function pass ready.

it not global , cannot called other scripts.

move outside of anonymous function make global.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -