快照Javascript<;脚本></脚本>;不在文本区

快照Javascript<;脚本></脚本>;不在文本区,javascript,textbox,Javascript,Textbox,我有一段Javascript代码来检测屏幕的资源。 现在,我的结果(1920 x 1080)位于一个文本框(输入)中,但我只希望它没有文本框。我需要怎么做 代码: <head> <script type="text/javascript" language="javascript"> function scrResolution() { var width = screen.width; var height = screen.h

我有一段Javascript代码来检测屏幕的资源。 现在,我的结果(1920 x 1080)位于一个文本框(输入)中,但我只希望它没有文本框。我需要怎么做

代码:

<head>

<script type="text/javascript" language="javascript">
    function scrResolution() {
        var width = screen.width;
        var height = screen.height;
        document.getElementById("txt_scrWidth").value = width;
        document.getElementById("txt_scrHeight").value = height;
    }
</script>
    </head>


<body onload="scrResolution();">
  <table width="200" border="0">
     <tr>
       <td>  
 Width :
<input name="txt_scrWidth" type="text" id="txt_scrWidth" size="5" />
      </td>
     </tr>
     <tr>
       <td>
           Height :  
 <input name="txt_scrHeight" type="text" id="txt_scrHeight" size="5" />
       </td>
     </tr>
    </table>
</body>
</html>

函数scrResolution(){
变量宽度=屏幕宽度;
变量高度=屏幕高度;
document.getElementById(“txt_scrWidth”)。值=宽度;
document.getElementById(“txt\U scrHeight”)。值=高度;
}
宽度:
高度:

可以尝试添加一个
span

<table width="200" border="0">
    <tr>
        <td>Width: <span id="txt_scrWidth"></span></td>
     </tr>
     <tr>
         <td>Height: <span id="txt_scrHeight"></span></td>
     </tr>
</table>

可以尝试添加
span

<table width="200" border="0">
    <tr>
        <td>Width: <span id="txt_scrWidth"></span></td>
     </tr>
     <tr>
         <td>Height: <span id="txt_scrHeight"></span></td>
     </tr>
</table>

函数scrResolution(){
变量宽度=屏幕宽度;
变量高度=屏幕高度;
document.getElementById(“txt_scrWidth”).innerHTML=宽度;
document.getElementById(“txt_scrHeight”).innerHTML=高度;
}
宽度:
高度:

函数scrResolution(){
变量宽度=屏幕宽度;
变量高度=屏幕高度;
document.getElementById(“txt_scrWidth”).innerHTML=宽度;
document.getElementById(“txt_scrHeight”).innerHTML=高度;
}
宽度:
高度:

如果您正在处理web应用程序,您可能对浏览器窗口视口的大小更感兴趣。以下是您将如何获得这些信息。如果用户更改屏幕大小,onresize侦听器将使sue确认它已更新

这是剧本

<script>
//make sure we update if the user resizes the browser
window.onresize = function() {
    showSize();   
};

function showSize() {
    document.getElementById("heightDisplay").innerHTML = document.height;
    document.getElementById("widthDisplay").innerHTML = document.width;
}

showSize();
</script>

//确保在用户调整浏览器大小时更新
window.onresize=函数(){
showSize();
};
函数showSize(){
document.getElementById(“heightDisplay”).innerHTML=document.height;
document.getElementById(“widthDisplay”).innerHTML=document.width;
}
showSize();
这是HTML

<div>
    Height: <span id="heightDisplay">Calculating...</span><br/>
    Width: <span id="widthDisplay">Calculating...</span>
</div>

高度:计算…
宽度:计算。。。
如果您正在处理web应用程序,您可能对浏览器窗口视口的大小更感兴趣。以下是您将如何获得这些信息。如果用户更改屏幕大小,onresize侦听器将使sue确认它已更新

这是剧本

<script>
//make sure we update if the user resizes the browser
window.onresize = function() {
    showSize();   
};

function showSize() {
    document.getElementById("heightDisplay").innerHTML = document.height;
    document.getElementById("widthDisplay").innerHTML = document.width;
}

showSize();
</script>

//确保在用户调整浏览器大小时更新
window.onresize=函数(){
showSize();
};
函数showSize(){
document.getElementById(“heightDisplay”).innerHTML=document.height;
document.getElementById(“widthDisplay”).innerHTML=document.width;
}
showSize();
这是HTML

<div>
    Height: <span id="heightDisplay">Calculating...</span><br/>
    Width: <span id="widthDisplay">Calculating...</span>
</div>

高度:计算…
宽度:计算。。。
我在这里没有看到文本区域。@darma我猜他指的是
输入
我不知道你说的“站在文本区域内”是什么意思,你的意思是这些值显示在你输入的内部吗?如果你想不使用文本框,你想用什么方式?你打算用它做什么?我是说输入字段,我只是想让它们出现在我的屏幕上,就像没有任何区域的字符串一样。我在这里看不到文本区域。@darma我猜他是指
输入
我不确定你说的“站在文本区域内”是什么意思,您的意思是这些值显示在您的输入中吗?如果您希望它不带文本框,您希望它以什么方式显示?你打算用它做什么?我是说输入字段,我只是想让它们在我的屏幕上像字符串一样,没有任何区域。很好,很乐意帮助:)很好,很乐意帮助:)