Loading...
Loading...
Loading...
Loading...

Windows Phone WebBrowser control: Manipulating Page DOM

View: 3010    Dowload: 0   Comment: 0   Post by: naruto   Category: Windows phone   Fields: Other

Basically, my code uses the WebBrowser InvokeScript function to manipulate the DOM of the page with the help of JavaScript.

The code is based on the concept described in another of my articles:

An Important Thing

Before you start invoking scripts, first set the IsScriptEnabled property to True, otherwise it will not work.

Using the Code

Below is an example of DOM manipulation through JavaScript:

string script = "function() { return document.getElementById('ElementID').innerText; }";
string elementInnerText = (string)WebBrowser1.InvokeScript("eval", script);

In the above example, I use a small script to get the InnerText property of an element in the web page.

Remarks

Unfortunately, I do not have the Windows Phone SDK installed. So I was unable to test the above code.

However, according to the theory and documentation, this is the right way.

If you get any exceptions when calling the method InvokeScript, try modifying your script. Remember that the same thing can be done in many ways.

I should point out that the same script may not work on all versions of Windows Phone, so you should test!

Original Source

This was originally posted on my personal blog (Brazilian Portuguese).
If you speak Portuguese, feel the urge to visit the original post:

Windows Phone WebBrowser control: Manipulating Page DOM

If you've programmed for Desktop (Windows Forms), you should know that WebBrowser control has a property called Document (of type HtmlDocument). This property allows us to manipulate the DOM of the page. However, that property does not exist in the Windows Phone WebBrowser control. But there is still a way to manipulate the DOM of the page, which is using JavaScript.

Posted on 16-05-2014 

Comment:

To comment you must be logged in members.

Files with category

  • Creating a Virtual Windows Phone 8 Development Environment

    Creating a Virtual Windows Phone 8 Development Environment

    View: 2328    Download: 0   Comment: 0

    Category: Windows phone     Fields: Other

    Like me, many developers didn't want to switch Operating Systems to develop for Windows 8 and Windows Phone 8 (WP8). After following the instructions in this tip, if you are one of these developers, you will be able to start developing for WP8 while...

  • Windows Phone WebBrowser control: Manipulating Page DOM

    Windows Phone WebBrowser control: Manipulating Page DOM

    View: 3010    Download: 0   Comment: 0

    Category: Windows phone     Fields: Other

    If you've programmed for Desktop (Windows Forms), you should know that WebBrowser control has a property called Document (of type HtmlDocument). This property allows us to manipulate the DOM of the page. However, that property does not exist in...

  • A Simple Guide To Mobile Phone File Transferring

    A Simple Guide To Mobile Phone File Transferring

    View: 2823    Download: 0   Comment: 0

    Category: Windows phone     Fields: Other

    With the extensive development of the mobile phone industry, our mobile phones are becoming more powerful than before. Today, mobile phones can process pictures, sound, and even video. We can get pictures from a phone's camera, or download them...

  • How to Publish your Windows Phone 8 Application on the Store

    How to Publish your Windows Phone 8 Application on the Store

    View: 1668    Download: 0   Comment: 0

    Category: Windows phone     Fields: Computers - Technology

    Almost of my friends asked me how to publish my Windows Phone 8 application on the store and this process can take time because your application must meet all the store requirements. So, in this tip, we will see together how to publish a Windows...

  • Air hockey

    Air hockey

    View: 1269    Download: 0   Comment: 0

    Category: Windows phone     Fields: Computers - Technology

    Introduction Have you ever played Air Hockey? Air Hockey is a fairly popular game in game centers and other places where people hang out. Not that many people had a chance to try it as a pre-installed game on operating systems. The purpose of the...

  • Pairs game

    Pairs game

    View: 876    Download: 0   Comment: 0

    Category: Windows phone     Fields: Computers - Technology

    Introduction Pairs, also known as Concentration, Memory cards, Pexeso etc. is a simple card game, where player must find two identical cards. This game is great for memory training and good to kill some time for kids and adults. Nevertheless, our...

  • Snake game for tablets and Smartphones

    Snake game for tablets and Smartphones

    View: 1354    Download: 1   Comment: 0

    Category: Windows phone     Fields: Computers - Technology

    Introduction The Snake game is a well-known game for mobile devices. The first time Snake made its debut was in 1997 and people usually know the game from Nokia 6110. Since then, this game changed many times and now it is time to adjust it for...

  • Work-Around for DataContractJsonSerializer ArgumentNullExceptions

    Work-Around for DataContractJsonSerializer ArgumentNullExceptions

    View: 1516    Download: 0   Comment: 0

    Category: Windows phone     Fields: Computers - Technology

    If you've tried using a DataContractJsonSerializer or a DataContractSerializer with Push Notification for the Windows Phone, you may have experienced an ArgumentNullException during deserialization. This can happen because the MemoryStream is...

 
File suggestion for you
File suggestion for you
File suggestion for you
File suggestion for you
Loading...
Loading...
Loading...
Loading...
File top downloads
File top downloads
File top downloads
File top downloads
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd