Shot Javascript <script></script> not in TextAre
Shot Javascript <script></script> not in TextArea
我在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>
<head>
<script type="text/javascript" language="javascript">
function scrResolution() {
var width = screen.width;
var height = screen.height;
document.getElementById("txt_scrWidth").innerHTML = width;
document.getElementById("txt_scrHeight").innerHTML= height;
}
</script>
</head>
<body onload="scrResolution();">
<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>
</body>
</html>
也许尝试添加一个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>
然后使用 JavaScript 设置innerHTML
:
function scrResolution()
{
var width = screen.width;
var height = screen.height;
document.getElementById("txt_scrWidth").innerHTML = width;
document.getElementById("txt_scrHeight").innerHTML = height;
}
如果您正在处理 Web 应用程序,您可能对浏览器窗口视区的大小更感兴趣。以下是您获取该信息的方法。如果用户更改屏幕大小,onresize 侦听器将起诉它已更新。
这是脚本
<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>
这是 HTML
<div>
Height: <span id="heightDisplay">Calculating...</span><br/>
Width: <span id="widthDisplay">Calculating...</span>
</div>
相关文章:
- 在<页眉>标签
- 如何更改<svg>标记为<img>用js标记
- Ckeditor-plugin:插入虚假元素add不情愿<p>标签前后
- Ajax文件加载和<输入>文件加载
- 为什么要使用0>javascript中的0
- 在<script src=“"></脚本>标签
- 等效于<script src=“;something1.json”></脚本>
- 是否在Script Src标记中包含Script<脚本>(JavaScript等)
- 显示“<script src='some.js'></脚本>"在Html文档中
- <script src=“//代码.jquery.com/jquery-1.11.1.min.js”></
- 类似于htmls<script src=“">xaml的标签
- Cordova接受<script src=“;myfile.js”>在<头部>
- 为什么我不得到“;NetworkError”;当我使用<script src=“;false _ ip”>
- 我可以在<script src=“;ftp://”>
- 如何使用<c: 对于每个>在JSP页面上的script标记中
- 为什么可以't我将JS代码置于<script src=“">代码</脚本>
- 将用户输入动态地附加到<script src=“">来自Java Script中的文本框
- 如何在Java Script中从长字符串中获取特定的字符串值?我想获得<tax_amt>标签
- 通过Javascript而不是<script src=“;external.aspx”>
- 迁移& lt; script>…& lt; / script>To .js文件失败