burnt1ce
burnt1ce

Reputation: 14897

How to hide javascript errors throw in iFrames?

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.

Upvotes: 0

Views: 1244

Answers (2)

Lee Kowalkowski
Lee Kowalkowski

Reputation: 11751

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.

Upvotes: 1

futureelite7
futureelite7

Reputation: 11502

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.

Upvotes: 0

Related Questions