javascript - Cross Frame Script Reuse -


i have application running in hta (msft html application) uses same script file on , on again throughout frames; hits 9 in places , application setup within various servers caching set immediate expire i'm trying carve out sort of performance in ball of mud.

is there 'good' way load main script file in top frame excuting within frames i.e.

--- top window ----

var mainscript = function(){  return (function(){ current functions etc here })(); }; 

--- sub frames ----

var framescript = top.mainscript; framescript(); 

and how affected window scope (would keep top window scope or in scope of frame-window)

the simplest method appears to give subframe id dynamically populate script loaded in master frame (using eval make js run);

i.e.

|> parent (aka top frame)

<script>top.windows = [];</script> <script id="myscript">     var test = function(){ top.windows.push(window); } </script> 

|>> subframe loads subsubframe in iframe

|>>> subsubframe

<script id="sf1"> document.getelementbyid("sf1").innerhtml = eval(top.window.document.getelementbyid("myscript").innerhtml); test(); </script> 

this works upto , beyond 8 frames deep within trusted domain (in .hta set application=true on frames this)

i used top.windows[] check scope. (type console.log(top.windows) in firebug)

nausiating , deep; google similar delay js loading/execution.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -