With MetaDOM style I wrote a little function to add runtime external scripts, this time compatible with all modern browser ;) This function is similar with Python import syntax, using From to specify a folder, or why not an uri, Import to add one or more script and finally an optional And method to call a callback on scripts loaded. Here You can view an example From("jsFolder") . Import("MyScript", "MyOhterScript") Seems cool? The first goal is to add dynamically one or more script in a simple and fast way. These script will be available on onload event if they're imported before this event. These scripts should be available on DOMContentLoaded too, but to be sure these script will be available You could add a callback using last method. From("jsFolder") . Import("MyScript", "MyOhterScript") . And(DoStuff) DoStuff is a function that do something with loaded scripts. What else You should do? You could load different ext...
Some time we could have a situation like this one: a site in a sub domain, called http://a.test.com another site in another sub domain, called http://b.test.com of course, a generic main site, called http://test.com A common problem between one or more sub domains, is the possibility to use, or call, scripts in the main domain, because of security restrictions. The simplest solution is to force, in the client side, the document.domain, specifying the common one, i.e. dcument.domain = "test.com"; In this way you can add, for example, an iframe, and read its content, or use parent window object from the iframe that points, for example, to http://test.com There are different reasons to do it, and one of them, is the ability to share a global, or common, space, between every sub domain, performing Ajax requests or whatever else we need. This object, saved in http://test.com, and loaded by every other sub domain, like "a" or "b", could solve in a really simple ...
Comments
Post a Comment