wp7 open another web browser control inside web broser control

风流意气都作罢 提交于 2019-12-13 03:56:36

问题


I have web browser control which contains many links and data. All these data are coming from web service.

Now i want open another web browser control when i click on first web broser link. so how it can be done?

my first web broser code is :

 webBrowser1.NavigateToString(htmlCode);

回答1:


You could have another webBrowser hidden under webBrowser1. Lets call it webBrowser2. Now when a user hits a link on webBrowser1, capture it a string lets say link. Now you can navigate to link using webBrowser2.Navigate(new Uri(link,UriKind.Absolute));. Do not forget to make webBrowser1 hidden and webBrowser2 visible.




回答2:


If i understand you, you want to intercept the onClick event in your first WB control (call this WB1), and open that page up (when the hyperlink is clicked) in another WB control (call this WB2)?

There are several ways you can do this, is this link set to open up in a new window? If so, you can intercept the NewWindow2 event is WB1 and run the following code in the NewWindow2 event of WB1... Set pDisp = WB2.object

(it may be ppDisp instead of pDisp, but it will show up when your event is auto generated, choose whichever object name shows up in your arguments list).

Otherwise, you can intercept this request during BeforeNavigate2 event of the WB1 event, check the URL property if it is the link you're interested in, and if so, cancel the current request and reissue a new one as below... (in the WB1 BN2 event)... Cancel = True ' This cancels the request WB2.Navigate2 URL, , "YourWB2sDocumentNameOrTargetFrameNameGoesHere"

Second line of code just reissues the request.

Of course, the YourWB2sDocumentNameOrTargetFrameNameGoesHere is the TargetFrameName (or the frame or document name of the top level document, or any iframe, in your WB2 control/window). This can usually be found in the BODY tags name= property, but you don't even need to do this if all you want is to load it as the top level document in WB2... if you just want to load it as the parent top level document in WB2, just do this... Cancel = True WB2.Navigate2 URL

By referencing WB2 it will just send the same URL request to WB2 window after cancelling WB1 request.

Let me know if you need more help and let me know how you get along.



来源:https://stackoverflow.com/questions/12189711/wp7-open-another-web-browser-control-inside-web-broser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!