티스토리 뷰

코드

var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///라이브러리명/파일.js"));
string.text = await Windows.Storage.FileIO.ReadTextAsync(storageFile);

관전 포인트

  • /// 슬래시 세 개. 결국 현재 앱 기준으로 해야 함
    • 아시겠지만 두 개 이후에 하나 더 나온 / 는 현재 앱 ID의 별칭입니다.
  • 파일은 빌드 작업 - "내용" 으로 포함

UWP WebView에 스크립트 삽입하기

참조함.

DOMContentLoaded ContentLoading 이벤트에서

string functionString = "var scriptObj = document.createElement('script');" +
                        "scriptObj.type = 'text/javascript';" +
                        "scriptObj.src = 'ms-appx-web:///라이브러리명/파일.js';" +
                        "var headObj = document.getElementsByTagName('head')[0];" +
                        "headObj.insertBefore(scriptObj, headObj.firstChild);";
await 웹뷰.InvokeScriptAsync("eval", new string[] { functionString });
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함