js |
JavaScriptタグが付けられた新着投稿 - Qiita |
プログラミングを始める時におすすめの無料サイト |
https://qiita.com/ono-ayumu/items/ff5ec7fe8e061197a48b
|
無料 |
2022-10-16 18:21:19 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
Redshift Streaming Injectionのデータ取得に失敗したときのメモ |
https://qiita.com/zumax/items/d8eb85759feee23ea004
|
edshiftstreaminginjection |
2022-10-16 18:38:40 |
技術ブログ |
Developers.IO |
Amazon FSx for NetApp ONTAPのKerberosを利用した転送時の暗号化設定を試してみた |
https://dev.classmethod.jp/articles/set_up_encryption_during_transfer_using_kerberos_in_amazon_fsx_for_netapp_ontap/
|
amazonfsxfornetappontap |
2022-10-16 09:35:51 |
海外TECH |
DEV Community |
From WebView to WebView2 in UWP |
https://dev.to/fanmixco/from-webview-to-webview2-in-uwp-2ehj
|
From WebView to WebView in UWPIn the old days accessing a local website in UWP was relatively easy Even if you wanted to load your third party libs The basic code you required The WebView lt WebView x Name webView Source ms appx web Assets index html NavigationStarting WebView NavigationStarting NavigationCompleted WebView NavigationCompleted gt Here you defined the Source and some extra events like NavigationStarting or NavigationCompleted for loading your JS or enabling JS interaction with your third party lib that you had to add as a reference in your main project Loading your third party lib private void WebView NavigationStarting WebView sender WebViewNavigationStartingEventArgs args sender AddWebAllowedObject CallJSCSharp new CallJSCSharp Adding extra code to load additional JS private async void WebView NavigationCompleted WebView sender WebViewNavigationCompletedEventArgs args string filename ms appx Assets js lang en json StorageFile file await StorageFile GetFileFromApplicationUriAsync new Uri filename string contents await FileIO ReadTextAsync file string arg contents await webView InvokeScriptAsync UpdateData arg And this is the function to execute extra functions from my app namespace CallJSInterface private Windows System Display DisplayRequest displayRequest public sealed partial class CallJSCSharp public void KeepScreenOn create the request instance if needed if displayRequest null displayRequest new Windows System Display DisplayRequest make request to put in active state displayRequest RequestActive Now what are all the changes required for the new WebView there are several changes to be considered The first one is to download the lib Microsoft UI Xaml from NuGet in your main project This lib allows you to add WebView It requires two changes Add this lib in your XAML s libs xmlns controls using Microsoft UI Xaml Controls And then you can add your WebView lt controls WebView x Name webView NavigationCompleted WebView NavigationCompleted gt Now comes the tricky parts The first change is about the Source With WebView we can only load external websites like bing com or facebook com Any local website is going to fail The new approach follows creating an asynchronous function that creates a virtual host it has to be called in the Constructor where you map your current local website like this private CoreWebView core wv private async void LoadLocalPage string fakeDomain myapp something string assetsLocation Assets string firstPage index html await webView EnsureCoreWebViewAsync core wv webView CoreWebView if core wv null core wv SetVirtualHostNameToFolderMapping fakeDomain assetsLocation CoreWebViewHostResourceAccessKind Allow webView Source new Uri https fakeDomain firstPage Every path that you have in your old app looks like this ms appx web Assets must be changed to Therefore if you loaded Bootstrap like this ms appx web Assets css boostrap min cssNow it is going to be like this The next part is how to interact with your third party lib and this part is complicated The first part involves adding a new and very specific C project Windows Runtime Component C WinRT to your solution that must be called WinRTAdapter You must install a lib from NuGet Microsoft Web WebView Add as a reference your third party lib Go to your C project properties go to Common Properties and choose WebView Here you have to do four changes Set Use WebView WinRT APIs to No Set Use the wvwinrt tool to Yes Set Use Javascript case to Yes Edit Include filters and add the following ones Windows System UserProfileWindows Globalization LanguageCallJSInterfaceCallJSInterface is the name of my third party s namespace You click on OK and built your C lib After you have built your C lib WinRTAdapter you must add it to your main project as a reference Now we need to do some changes to be able to invoke the functions from our third party lib The first one is to register it We do it in the same LoadLocalPage function from before or on NavigationCompleted var namespacesName CallJSInterface var dispatchAdapter new WinRTAdapter DispatchAdapter core wv AddHostObjectToScript namespacesName dispatchAdapter WrapNamedObject namespacesName dispatchAdapter Where CallJSInterface is your namespace After this you need to register your function in your JS like this var callJS if chrome amp amp chrome webview chrome webview hostObjects options defaultSyncProxy true chrome webview hostObjects options forceAsyncMethodMatches Async chrome webview hostObjects options ignoreMemberNotFoundError true window CallJSInterface chrome webview hostObjects sync CallJSInterface callJS new CallJSInterface CallJSCSharp Where CallJSInterface is one more time your namespace Now you can invoke JS like this the async is mandatory callJS async KeepScreenOn The last part is how to load your scripts as before The old function InvokeScriptAsync UpdateData arg doesn t exit The best way is to create a class Extension like this public static class Extensions public static async Task lt string gt ExecuteScriptFunctionAsync this WebView webView string functionName params object parameters string script functionName for int i i lt parameters Length i script JsonConvert SerializeObject parameters i if i lt parameters Length script script return await webView ExecuteScriptAsync script Now from the NavigationCompleted you can load it in the old way await webView ExecuteScriptFunctionAsync UpdateData arg With all these steps you can do it again your entire process Follow me at LinkedInYouTubeInstagramCyber ProphetsSharing Your Stories |
2022-10-16 09:18:51 |
海外ニュース |
Japan Times latest articles |
Kofu outlasts Hiroshima to claim maiden Emperor’s Cup title |
https://www.japantimes.co.jp/sports/2022/10/16/soccer/emperors-cup-ventforet-sanfrecce/
|
Kofu outlasts Hiroshima to claim maiden Emperor s Cup titleThe J League second division team held the fort against its J opponent earning its first major trophy after a dramatic penalty shootout at Nissan Stadium |
2022-10-16 18:13:24 |
ニュース |
BBC News - Home |
Get behind Liz Truss, Chancellor Jeremy Hunt tells Tory MPs |
https://www.bbc.co.uk/news/uk-politics-63275544?at_medium=RSS&at_campaign=KARANGA
|
jeremy |
2022-10-16 09:11:57 |
ニュース |
BBC News - Home |
Evin prison fire: Gun shots and sirens heard at Iran's notorious detention centre |
https://www.bbc.co.uk/news/world-asia-63271817?at_medium=RSS&at_campaign=KARANGA
|
centreit |
2022-10-16 09:28:04 |
ニュース |
BBC News - Home |
Leeds fire: Emergency crews tackle city centre blaze |
https://www.bbc.co.uk/news/uk-england-leeds-63273534?at_medium=RSS&at_campaign=KARANGA
|
authority |
2022-10-16 09:53:55 |
北海道 |
北海道新聞 |
佳子さまガールスカウト式典出席 問題解決目指す活動表彰 |
https://www.hokkaido-np.co.jp/article/746109/
|
佳子さま |
2022-10-16 18:22:34 |
北海道 |
北海道新聞 |
成田の滑走路延伸、工事本格化へ 月内にも着手 |
https://www.hokkaido-np.co.jp/article/746119/
|
成田国際空港 |
2022-10-16 18:29:00 |
北海道 |
北海道新聞 |
J2甲府、サッカー天皇杯初優勝 J1広島とのPK戦を制す |
https://www.hokkaido-np.co.jp/article/746096/
|
全日本選手権 |
2022-10-16 18:12:25 |
北海道 |
北海道新聞 |
学生柔道、男子は天理大が初優勝 女子は東海大 |
https://www.hokkaido-np.co.jp/article/746117/
|
兵庫県尼崎市 |
2022-10-16 18:23:00 |
北海道 |
北海道新聞 |
道南91人感染、函館は60人 新型コロナ |
https://www.hokkaido-np.co.jp/article/746116/
|
医療機関 |
2022-10-16 18:19:00 |
北海道 |
北海道新聞 |
がれきなど2・3トン不法投棄疑い 男2人逮捕 札幌北署など |
https://www.hokkaido-np.co.jp/article/746107/
|
不法投棄 |
2022-10-16 18:16:01 |
北海道 |
北海道新聞 |
トランポリン、西岡3連覇 宇山が初V、全日本選手権最終日 |
https://www.hokkaido-np.co.jp/article/746112/
|
全日本選手権 |
2022-10-16 18:07:00 |
北海道 |
北海道新聞 |
日豪首脳、新安保宣言へ 天然ガス供給協力要請も |
https://www.hokkaido-np.co.jp/article/746111/
|
天然ガス |
2022-10-16 18:05:00 |
北海道 |
北海道新聞 |
交雑多数で在来種消滅懸念、広島 オオサンショウウオ |
https://www.hokkaido-np.co.jp/article/746110/
|
広島県内 |
2022-10-16 18:05:00 |
北海道 |
北海道新聞 |
陸自北部方面隊が創隊70周年記念行事 |
https://www.hokkaido-np.co.jp/article/746108/
|
北部方面隊 |
2022-10-16 18:03:00 |
コメント
コメントを投稿