Launch IE from app passing HTML content - windows-phone-7

I need to launch IE from my WP7 app and load the HTML to create the page dynamically. The HTML is read from a web service and can change at any time, so I'm not able to just store the HTML in a file. Is there a way to do this -- much like you do with WebBrowser.NavigateToString(strHtml)?
-Thanks!

If you are attempting to open your HTML content in an embedded WebBrowser control you can use the "NavigateToString" function and pass it the HTML content you would like to load.
If you are trying to open it in the native IE browser on the device then I would recommend putting state information in the URL and opening the page directly with any parameters required to replicate the view in the browser via the WebBrowserTask. This way you wouldn't technically be opening the HTML code from your app but you would be able to ensure that the HTML content loaded from your service is correct based on your query parameters.

Are you looking for WebBrowserTask?

Related

Delphi: Log the GET request URLs used in Websites that are updating content via AJAX (TWebbrowser)

Using a TWebBrowser in Delphi, I'm showing a website that uses JSON to update its content. To get the source code of the newly updated content and load it into a Memo, I believe I have to get the URLs of the GET requests. Unfortunately, these are always different and generated with an encrypted Javascript. Is there any way to list the URLs the GET requests go to in a similar way like FireBug does in its console view?
Thanks a bunch!!!

Making content accessible on Addon SDK

I am developing an addon using Firefox's Addon SDK (v. 1.11). My extension dynamically creates an iframe on each website and then loads an html file which includes other resources such as images, font files, etc. from the add on's local directory.
Problem
When loading any of such local resources (i.e.: "resource://" schema), the iframe fails to display them and a message is thrown:
Security Error: Content at http: //www.XXX may not load or link to
resource://XXX
This is a security measure introduced on Firefox 3. When developing without the Addon SDK, the way around it is declaring a directory with "contentaccessible=yes", making the directory's contents accessible to anyone, including my add on. However, I have not been able to find similar functionality using the Addon SDK. Is there a better way of using local data on an iframe that my addon creates and inserts into a page?
I don't think you can directly load an iFrame that points to a resource inside your URL. The browser complains because it's either breaking same origin policy or cross site scripting one. I can't remember which one right now.
if it is html content you want to load you can always inject it into the DOM and then send a message to the document object using the events API to display your custom html. I've done this in the past and it works.
so from main.js send a message to content script which will then inject your iframe html into the DOM and then you can send the document object a message to display it.
I hope this helps.
Not sure if this was the case when you posted the question, but it appears that "resource://" should no longer be used with the Addon SDK.
If you're using the resource inside of an HTML file in the extension, you can reference it locally, otherwise you should use data.url('whatever.jpg') and pass around that value as needed.
Full info is here: http://blog.mozilla.org/addons/2012/01/11/sdk-1-4-known-issue-with-hard-coding-resource-uris/

How to parse HTML page data in Windows Phone 7?

I want to do the below two tasks In Windows Phone 7 application.
1.Navigate to a web page (e.g.http://www.FlightsInd.com) and get the HTML page data.I wnat to ensure that all the Document data is completely downloaded.
In C#.Net i am doing this using below code:
WebBrowser objWB = new WebBrowser();
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
objWB.Navigate("http://www.FlightsInd.com")
here once the DocumentCompleted event is fired it means all the data in that request is downloaded.
2.Parse HTML page elements data.
In C#.Net i am doing this using below code.
doc = webBrowser1.Document;
btnElem = doc.GetElementById(streleid);
Can anyody help me with the equivalent classes/code for the above two implementations ?
Use WebBrowser Windows Phone control
To Navigate to your page
browser.Navigate(new Uri("http://www.FlightsInd.com"));
To understand that navigation completed and content is loaded
WebBrowser.Navigated Event
WebBrowser.LoadCompleted Event - Occurs after the WebBrowser control has loaded content.
WebBrowser.NavigationFailed Event - to track navigation failures
The WebBrowser class events are raised in the following order: Navigating, Navigated, and LoadCompleted.
To get Html source
WebBrowser Windows Phone control contains special function to save the source for the HTML content currently displayed in WebBrowser control as a string:
string html = browser.SaveToString();
To parse Html
Look at HTML Agility Pack
What is the best way to parse html in C#?
Parsing HTML String
PS. Alternatively you can use webBrowser.InvokeScript (C#) with combination of js eval to invoke any js command which can use window.external.notify inside it to pass results back to C#.
If I get your question right, you can use web browser isBusy property to track if its still downloading data and sleep while its still busy.
For parsing html document you can use NSoup library to parse the html just like jQuery. Its a port from java's JSoup library.
http://www.developerfusion.com/project/98472/nsoup/
Syntax explained here:
http://jsoup.org/cookbook/extracting-data/selector-syntax
If you own the webpage you are navigating to, you can use window.external.notify(document.documentElement.innerHTML) in your javascript to pass the document html to native layer. Then you would catch the value in your native code using ScriptNotify.
A little more complex, but if you don't own the webpage, you could host your own webpage, open an iframe with the original page, and get the html from the iframe.
See here for more info on window.external.notify: http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.scriptnotify(v=vs.95).aspx

Html5 web pages in a window

I'm trying to get a web page in a window within a web page, so basily what I want is something like a standed os,
you have a exe it opens with in a window, well I want that but in HTML5
Would I use Ajax?
Anything would be helpful at this stage!
Thanks jrop
For your problem you don't need HTML5. You can solve it by using jQuery.
jQuert window plugin (You can choose one of them depending on your need):
http://fstoke.me/jquery/window/
http://hernan.amiune.com/labs/jQuery-Windows-Engine-Plugin/jQuery-Windows-Engine-Plugin.html
http://swip.codylindley.com/DOMWindowDemo.html
http://pierrebertet.net/projects/jquery_superbox/
If you want an actual window then you would use open. If you want a pseudo-window inside a page, then you would use <iframe>. If you don't want an actual page, but just a chunk of HTML then you would use DOM manipulation to create the elements in the page (and possibly Ajax techniques to get the data over HTTP if you don't have it in the page already).

Load HTML in Firefox Extension

I want to create a Firefox Extension which will display a webpage. It will be like user should write a something in browser like "about:" or even a button would do ?
How can i load the WebPage in Firefox. The user should have a feel that a webpage is being loaded.
PS: I have javascript and CSS in that Page.
If i cannot make then what changes do i need to make in the web page for that change.
I also want to connect to a server and fetch XML data and want to display process that data and and display it on the page. I am developing this extension as my page is static and HTML/Javascript does not allow cross domain queries. I hope that cross-domain queries are possible if i use extension.
There is Browser XUL object that acts a an standalone browser. You can load any document inside that.

Resources