Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何重置UWP WebView';内容缩放因子_Javascript_C#_Html_Uwp - Fatal编程技术网

Javascript 如何重置UWP WebView';内容缩放因子

Javascript 如何重置UWP WebView';内容缩放因子,javascript,c#,html,uwp,Javascript,C#,Html,Uwp,我正在尝试将c#UWP中webview的内容zoomfactor重置为1或100% 我的问题是如何做到这一点 有没有办法告诉webview本身通过c#缩回1.0 比如webView.ContentScale=1.0 或 我必须在html中调用什么来告诉它缩放到100% 我会这样做来执行单击 webView.InvokeScriptAsync("eval", new string[] { "document.elementFromPoint(" + 555 + ", " + 355 + "

我正在尝试将c#UWP中webview的内容zoomfactor重置为1或100%

我的问题是如何做到这一点

  • 有没有办法告诉webview本身通过c#缩回1.0
比如
webView.ContentScale=1.0

  • 我必须在html中调用什么来告诉它缩放到100%
我会这样做来执行单击

webView.InvokeScriptAsync("eval", new string[] { "document.elementFromPoint(" + 555 + ", " + 355 + ").click();" });

如果您知道如何在html/js中重置zoomfactor,也会对我有所帮助。我会通过求值添加代码并调用它

信息:Microsoft Edge渲染引擎用于这些Web视图

我不想只是重新加载页面,因为可能有一些用户更改,这些更改可能会丢失

来自德国的亲切问候

有没有办法告诉webview本身通过c#缩回1.0

恐怕目前还没有这样的方法可以直接设置网站的内容规模

如果您知道如何在html/js中重置zoomfactor,也会对我有所帮助。我会通过求值添加代码并调用它

正如您所想,我们可以在
WebView
将加载的页面上添加一个Javascript函数,并通过方法调用该函数。我们可以将属性设置为该函数中的样式,以根据需要重置缩放因子。例如,我们将以下HTML加载到
WebView
,并创建
ZoomFunction

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <script type="text/javascript">
        function ZoomFunction(Percentage) {
            var mybody = document.getElementById("mybody");         
            mybody.style.zoom = Percentage + "%";
        }
    </script>
</head>
<body id="mybody" style="margin:0px;padding:0px; overflow:hidden;zoom:50%"> 
      This content is shown for zoom in and out. 
</body>
</html>
更多详情请参考

 await MyWebView.InvokeScriptAsync("eval", new string[] { "ZoomFunction(100);" });