Javascript x-ms-window命令拖动和链接屏幕分辨率

Javascript x-ms-window命令拖动和链接屏幕分辨率,javascript,php,html,visual-studio-2013,Javascript,Php,Html,Visual Studio 2013,这是我的密码。我试图让它嵌入一个基于Windows8.1应用程序屏幕分辨率的网页,但是我如何调用.js脚本中的变量呢 <body> <script> function myFunction() { var x = screen.width; var y = screen.height; document.getElementById('insert').width = x; document.getElementById('insert')

这是我的密码。我试图让它嵌入一个基于Windows8.1应用程序屏幕分辨率的网页,但是我如何调用.js脚本中的变量呢

<body>
<script>
function myFunction() {
    var x = screen.width;
    var y = screen.height;
    document.getElementById('insert').width = x;
    document.getElementById('insert').height = y;
}
</script>
<x-ms-webview id="insert" src="http://subgamer.com" width=0 height=0 ></x-ms-webview>

请连同代码一起解释

我强烈建议使用JQuery这样的库,因为它使代码更加整洁,而且功能非常强大。这只需使用以下代码行即可完成:对于web连接的站点,如果是本地使用,则需要在本地下载该文件

<script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>
$函数{};告诉它在页面加载后运行。 $'insert'选择id为'insert'的元素,其余的只是指定高度和宽度值

如果窗口将在任意点调整大小,则可以将其放入函数中

function resizeInsert(){
    $('#insert').height($(window).height());
    $('#insert').width($(window).width());
}
并在加载页面和调整屏幕大小时调用它,如下所示:

$(function(){
    resizeInsert();
});

$( window ).resize(function() {
    resizeInsert();
});
这样,“插入”元素将始终保持窗口的完整大小

$(function(){
    resizeInsert();
});

$( window ).resize(function() {
    resizeInsert();
});