Javascript is not getting executed when DOM/HTML is loaded browser cache - javascript

I am caching the dynamic content using the ETAG. There is javascript in tag which in turn located at the end of body tag. This script tag make changes in DOM elements. But when DOM/HTML is loaded from browser cache, javascript is not getting executed.
Any work around to make this work?
Also I am observing caching is working fine with Chrome and mozilla, but not with OPERA. Is there any specific reason/bug in opera, which is causing this issue?

Related

How do you debug dynamically loaded javascript in Firefox?

With Chrome, you can add
//# sourceURL=/js/dynamicFile.js
to enable the ability to debug a file that is loaded via ajax. But it does not appear to work on Firefox. Is there another method?

Sandbox iframe attribute isn't preventing redirects in FIrefox

I'm trying to get iFrame sandboxing to work, and Firefox is giving me trouble.
<iframe src="" scrolling="no" sandbox=""></iframe>
I use jQuery to set the iFrame's src attribute to one of several different pages. But my target pages have JavaScript in them that makes them break out of my iFrame. I counter that with the sandbox attribute, which is supposed to prevent JavaScript from running inside the iFrame. This works great in Chrome and Internet Explorer, but in Firefox as soon as I load the target page into the iFrame it takes over the whole window.
Firefox's documentation says it fully supports the sandbox attribute. Am I doing something wrong? Installing NoScript and telling my browser not to run JavaScript from the target site makes everything work fine, but obviously I don't want Firefox users to have to install an addon before my site will work.
If you are manipulating or setting the sandbox attribute after the iframe is in the DOM, it will completely ignore the setting. You must set it before the iframe element is added to the DOM.

IE9 and head.js loads script twice

Using Head.js (0.9) and verifying the loading of scripts from IE9, the Network pane of IE9 developer shows that the javascripts are loaded twice.
First time, the script is loaded with HTTP result code 200, thereafter the same script is reloaded with result code 304 (not modified).
However, the script pane and the script block drop down displays the scripts as being loaded twice. This in turn makes one of the scripts (sIFR.js) resetting its global sIFR object.
I'm suspecting the double-loading is causing this.
Note: Chrome and Firefox both work as expected.
Anyone else having seen this odd behaviour?

Reload js and CSS on Chrome and Firefox

I heard about xRefresh that doesn't support new browserrs and firebug, also Reloadit that works only with ie. How can I reload updated js and css without refreshing whole page on Chrome or FF?
I think correct way is using http headers to tell browser not to cache certain images, javascripts etc.
http://www.mnot.net/cache_docs/

Hard to debug situation (or bug) in Opera

Ok, I'll do my best.
There's this page http://tiu.ru/image/tmp/test_2.html , which looks differently in Opera then in Chrome and Firefox (maybe others).
It evaluates a javascript code inside <div></div>, that does document.write("") of a piece of another HTML code with <script>, that evaluates JS code that asks Google Ads to write ads.
Google Ads writes it's container and container's content (which loads advertising from Yandex) ((maybe you'll need to disable adblock to see ads, but you can just view the screenshot)).
And the problem is that in Opera it writes that content outside the original div somehow.
Screenshot of result for Chrome:
Screenshot of result for Opera:
If you take that code inside document.write() and put it just as usual HTML code -- everything works well. See http://tiu.ru/image/tmp/test_3.html
I can't figure out how to debug that google ads code, that's why I ask for help. Thank you.
p.s.: you can save page to localhost somewhere and open it, ads won't be loaded, but DOM tree will be the same wrong.
Thank you very much!
Well, you add a script tag with document.write() that does document.write() to add the one that calls GA_googleFillSlot, which itself does document.write() to add a SCRIPT with SRC set to a doubleclick.net URL which calls back into google_ads.js to trigger another document.write() that adds an inline SCRIPT containing another document.write() call to add another external script, this time loading context.js from an.yandex.ru, and it looks like context.js also contains code to add yet two more external scripts to the document. But at this point the damage already happened: although a loading external script inserted with document.write() should block parsing, something odd happens when the doubleclick.net script loads and calls back into google_ads.js that makes Opera close the parent DIV.
Let's see what the DOM looks like the moment DoubleClick calls back to google_ads - by setting a breakpoint in GA_googleSetAdContentsBySlotForSync and using Opera Dragonfly. There we go: on entering this script, the DOM is still OK, the DIV is not closed - but when this script thread does document.write() to add <div id=google_ads_div_ru__context_informers_addon_360x90_ad_container> with comments, markup and scripts inside, something about that new content makes Opera believe it needs to close the former document.write()-inserted DIV. It's a parsing bug deep inside the handling of multiple nested document.write()s, I guess.
This will work fine with Opera's upcoming HTML5 parser. If at all possible for you, don't worry about it and wait until Opera 12 sorts it all out.
Opera has a strict XHTML parser. Try wrapping your javascript in CDATA tags so the parser will ignore the < and & characters as well as any other illegal characters in your script:
<script type="text/javascript">
/* <![CDATA[ */
// put your js code here
/* ]]> */
</script>

Categories

Resources