Public WebView view;
var url = "javascript:(function() { var parent = document.getElementsByTagName('head').item(0);var script = document.createElement('script'); script.type = 'text/javascript'; script.innerHTML =\""+ content + "\";parent.appendChild(script)})()";
view.LoadUrl(url);
Asked
Active
Viewed 35 times
-1
-
Possible duplicate of [How to add DOM element script to head section?](https://stackoverflow.com/questions/18784920/how-to-add-dom-element-script-to-head-section) – Daniel Mizerski Jun 19 '17 at 12:40
1 Answers
0
You need to use HttpUtility.JavaScriptStringEncode(content) to encode this string:
\
"
'
into this:
\\
\"
\'

JanErikGunnar
- 211
- 1
- 7