In which order is the content on a HTML page loaded and executed?
I have a concrete question, but understanding the mechanics of the process would be better, hence the title.
There is a block of text, which can be hidden or displayed to a user, based on his "Local Stored object" cookies. Therefore, I need to load .swf
, which would act a as bridge between JavaScript and Flash. Then Javascript would get cookies from Flash and decide, whether it is necessary to hide the text. Is it possible not to wait till the page loading finishes, thus showing/not showing the text block when the page still loads Images, other scripts and so on? This must depend on when object
will be loaded, I guess, but, perhaps, if inline JavaScript is executed as soon as it is received, there is a way to force .swf
loading before the whole page has loaded.
BTW, I need cookies to be preserved across browsers, that's why I can't use server-side o开发者_C百科r document.cookie
methods
Thanks
It "Executes" in the order of the file. However, using flash jsut to pass cookies is a bad idea (You can make cookies in javascript alone, try that)
Also, for what you want, you should use php or another server side scripting language that will set it to the default state before even sending it to the client.
To be honest, using Flash cookies is evil (violates privacy since most people don't know how to clear them, or even know that they exist), but there are several JavaScript libraries available that claim to make use of them:
persist.js, available under the MIT License, is another. By default, it will choose the highest-capacity storage backend (Google Gears is preferred), but you can change that to prefer Flash cookies.
SWFStore is also available under the MIT License.
Truly evil: evercookie is one that uses quite a number of methods, including Flash. Unless one clears all the storage locations before visiting your site again (even once), the cookie will remain.
精彩评论