Webbrowser in Windows Phone opens a new window

Source: Internet
Author: User

Webbrowser in Windows Phone does not support opening new windows.That is, when you click a hyperlink with target = "_ blank" on the page, the hyperlink will not be opened. How can this problem be solved?

The idea is: we can replace all target = "_ blank" on the page with target = "_ Self", so that when you click the hyperlink, this link will be opened in the original webbrowser.

So how to implement it?

There are two ideas:

1. After the webpage is loadedSource codeGet it, and replace this string (this will be a little problem, think about Chinese ...)

2. When the webpage is loaded, JavaScript is called.CodeAnd use js to implement replacement.

This article will briefly introduce the implementation of the second method. As for the first method, you can study it on your own.

Webbrowser has an isscriptenabled attribute. When we set it to true, we can call the front-end JS function in the post code. The Code is as follows:

Webbrowser1. Invokescript("Test ");
Webbrowser1.invokescript ("Test2", "1 ");

The parameter is a function name or a function name plus a parameter.

So we can use this method in the event of webpage content loading to replace target = "_ blank" with target = "_ Self". The specific code is as follows:

 

In this way, after the web page is loaded, the target = "_ blank" in the original page has been replaced with target = "_ Self", so that you can click the hyperlink normally and then go to webbrowser.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.