Tutorial :How to hide javascript errors throw in iFrames?



Question:

I have an iFrame that shows external web pages through one of my proxies that I control. But this proxy doesn't handle javascript properly most of the time, the external pages throws javascript errors. Javascript doesn't need to work as it's not important.

What can i do to hide these javascript errors? They are annoying and I may have more than one of these iFrames pointing to different external sources.


Solution:1

Could your proxy rewrite the HTML? If you don't even care whether the HTML is valid, you can replace <script with <!--script, /script> with /script-->. and invalidate any event handler attributes e.g. replace on[a-z]+= with *onnull=.

The only JavaScript that could run then is within CSS expressions in Internet Explorer.


Solution:2

I suppose just use the proxy to parse and replace all script tags and events. Since all of those tags have a regular pattern, you can just use regex to eliminate all script tags and all javascript events if not important.

Regex to remove script:

<script.*?</script>  

Will remove all characters between script tags, but you should also remove the on x and javascript: addresses as well. More on this later.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »