0

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.

2
  • What kind of proxy do you mean? Could you inject code into the pages you load? Commented Jun 26, 2009 at 15:52
  • Curious if you ever solved this one. Commented Dec 28, 2018 at 4:16

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.