Usually use localProgramToHtm5Will not use your own browser to carryHTML5Because the cost and efficiency are not guaranteed.
InMicrosoft. Phone. ControlsIn the Assembly, Microsoft providesWebbrowserControl, you can setWebbrowserControlUriAttribute or usageNanvigateMethod to navigateUriTo displayHTML5Page.
Example:
grid x : name =" layoutroot " background =" Transparent ">
phone : webbrowser x : name =" Browser " isscriptenabled =" true "/>
</Grid>
IsscriptenabledProperty indicates whether the current browser control supports scripts.
InAssetsThere are three items in the folder FirstJqueryOfJSFramework,Sandcu.htmlIsHTML5Page, using15ItemsCanvasTo drawSceneIn15As a simple puzzle.
InMainpageBackgroundCodeMedium
PublicMainpage ()
{
Initializecomponent ();
Using(IsolatedstoragefileStore =Isolatedstoragefile. Getuserstoreforapplication ())
{
If(! Store. fileexists ("Sandcu.html"))
{
Createfile (store,"Sandcu.html",Application. Getresourcestream (New Uri("Assets/sandcu.html",Urikind. Relative). Stream );
}
If(! Store. fileexists ("Jquery. js"))
{
Createfile (store,"Jquery. js",Application. Getresourcestream (New Uri("Assets/jquery. js",Urikind. Relative). Stream );
}
If(! Store. fileexists ("Scene.jpg"))
{
Createfile (store,"Scene.jpg",Application. Getresourcestream (New Uri("Assets/scene.jpg",Urikind. Relative). Stream );
}
}
Browser. Loaded + = (S, e) => browser. Source =New Uri("Sandcu.html",Urikind. Relative );
}
Because no relative path is available in the resource fileUriTherefore, the common practice is to copy the required resources to the independent storage.CreatefileThe function is used to write the resource file into the independent storage with the specified name, which is not described here.
ProgramRunAfter getting up, you can seeSandcu.htmlAlready displayed inWebbrowser.
Currently, the existing cross-platform development frameworks includePhonegapBut the execution efficiency is low.
PassWebbrowserBuilt-inInvokescriptCan be called directly.
Slave HTML5 Code call Native Method
SlaveJSYou can throw a parameter to the bearer browser. The browser processes the parameter after receiving it.
SetSandcu.htmlRewrite InDivOfOnclickThe event is like an external containerWebbrowserThrow the parameter"Sandcu"
In the browserScriptpolicyAdd event handlerBrowser_scriptpolicy()
Windows Phone game ( XNa ) And HTML5 Interaction
Omitted
2.4 phonegap Framework Analysis
Http://www.phonegap.cn/
PhonegapYesreIOSAndAndroidA cross-platform application framework that is widely used on Alibaba Cloud.Windows Phone 7Now supportsMangoLater versions (includingMango)
Structure structure:
The topic program framework andWebFramework Structure,
Third-party class libraries mainly useNewtonsoftOfJSONLibrary
The main program framework consists of local calls and the terminal intermediate layer
TheNaticeexecution. TTIs a template file, which can be ignored
PluginAll files under the folder are localAPICall intermediate layer, asynchronousCommandIsHtmlPage call command, passed in the form of parameters, usePhonegapAfter the framework, the default start page isIndex.html, As shown belowMessageBoxTo display device information as an ExamplePhonegapExecute the process.
InLiLabelOnclickEvent bindingNavigator. Notification. Alert ()Function, and specify the information to pop up.
InPhonegap. js(Located inWWWFolder.
Phonegap.exe c =Function(Nativemethodandargs)
{
Window. External. Policy (nativemethodandargs );
};
WhileExecFunctions are uniformly notified in an external browser, and function names and parameters are passed back in the form of string parameters.
InMainpageIn the background codeBrowserscriptpolicyTo process
InProcessjavascriptFunction to analyze the callback parameters. asynchronous callback is used for local calls.InvokescriptMethod to callJSInCallback.