Hot File

Windows Phone WebBrowser control: Manipulating Page DOM

View: 2722    Dowload: 0   Comment: 0   Post by: naruto  
Author: none   Category: Windows phone   Fields: Other

9 point/7 review File has been tested

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.

Introduction

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

Windows Phone WebBrowser control: Manipulating Page DOM Posted on 16-05-2014  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. 1.2857142857143/10 2722

Comment:

To comment you must be logged in members.

Files with category

  • Creating a Virtual Windows Phone 8 Development Environment

    View: 2042    Download: 0   Comment: 0   Author: none  

    Creating a Virtual Windows Phone 8 Development Environment

    Category: Windows phone
    Fields: Other

    0/4 review
    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

    View: 2722    Download: 0   Comment: 0   Author: none  

    Windows Phone WebBrowser control: Manipulating Page DOM

    Category: Windows phone
    Fields: Other

    0.64285714285714/7 review
    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

    View: 2496    Download: 0   Comment: 0   Author: none  

    A Simple Guide To Mobile Phone File Transferring

    Category: Windows phone
    Fields: Other

    0.9/5 review
    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

    View: 1440    Download: 0   Comment: 0   Author: none  

    How to Publish your Windows Phone 8 Application on the Store

    Category: Windows phone
    Fields: Computers - Technology

    1.5/3 review
    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

    View: 896    Download: 0   Comment: 0   Author: none  

    Air hockey

    Category: Windows phone
    Fields: Computers - Technology

    0/6 review
    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

    View: 581    Download: 0   Comment: 0   Author: none  

    Pairs game

    Category: Windows phone
    Fields: Computers - Technology

    0/1 review
    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

    View: 1035    Download: 1   Comment: 0   Author: none  

    Snake game for tablets and Smartphones

    Category: Windows phone
    Fields: Computers - Technology

    0/9 review
    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

    View: 1296    Download: 0   Comment: 0   Author: none  

    Work-Around for DataContractJsonSerializer ArgumentNullExceptions

    Category: Windows phone
    Fields: Computers - Technology

    1/4 review
    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...

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd