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.

Note

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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.