I have an issue with inline vs included Javascript -


i relatively new javascript , trying understand how use correctly.

if wrap javascript code in anonymous function avoid making variables public functions within javascript not available within html includes javascript.

on loading page javascript loads , executed on subsequent reloads of page javascript code not go through execution process again. there ajax call using httprequest php file , passes returned data callback function in onsuccess processes data, if call function httprequest within html in

<script type="text/javascript" ></script> 

block on each page load i'd set - have inject entire javascript code block work on page load, hoping can educate me.

if aren't using javascript framework, suggest it. use mootools, there many others solid (prototype, yui, jquery, etc). these include methods attaching functionality domready event. problem with:

window.onload = function(){...}; 

is can ever have 1 function attached event (subsequent assignments overwrite one).

frameworks provide more appropriate methods doing this. example, in mootools:

window.addevent('domready', function(){...}); 

finally, there other ways avoid polluting global namespace. namespacing own code (mysite.foo = function...) avoid potential conflicts.

one more thing. i'm not 100% sure comment problem have specific page load event. saying code needs executed when ajax returns well? please edit question if case.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -