Injecting Web Page Behavior

On occasion you may want to invoke some JavaScript on a third-party web page, in which case relying on a named JavaScript function becomes impossible. Fortunately, JavaScript’s eval function gives us the power to execute arbitrary JavaScript.


Be aware that it is possible to override the JavaScript eval function, which may result in less than complete reliability for the technique presented in this section. Overriding eval is, however, rare, and web pages that do this do not comply with the ECMAScript 5 specification.

To demonstrate the execution of arbitrary JavaScript, another button has been added to the WebBrowserWithScriptingView.xaml page. Clicking the button causes a script to be invoked on the web page, ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.