V
vunet.us
I have an HTML page with included JS file like:
<script language="javascript" type="text/javascript" src="file.js"></
script>
The file.js has a set of functions and global initializer for some
html object. Hoever, I want to hide my html object with display:block
CSS property. As a result, object in JS file fails to be initialized
for a hidden object. I decided to call JS file when needed (i.e. when
HTML object becomes visible on page) like this:
function getJSOnDemand(){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.id = 'tinyMCEScriptInitializer';
script.type = 'text/javascript';
script.src = "file.js";
head.appendChild(script);
}
Howeverm it did not work and still fails to initialize HTML object, as
if it does not see it. Could you recommend how to call JS file when it
is needed or how to deal with initialization of the html object which
is hidden on the page?
Thank you.
<script language="javascript" type="text/javascript" src="file.js"></
script>
The file.js has a set of functions and global initializer for some
html object. Hoever, I want to hide my html object with display:block
CSS property. As a result, object in JS file fails to be initialized
for a hidden object. I decided to call JS file when needed (i.e. when
HTML object becomes visible on page) like this:
function getJSOnDemand(){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.id = 'tinyMCEScriptInitializer';
script.type = 'text/javascript';
script.src = "file.js";
head.appendChild(script);
}
Howeverm it did not work and still fails to initialize HTML object, as
if it does not see it. Could you recommend how to call JS file when it
is needed or how to deal with initialization of the html object which
is hidden on the page?
Thank you.