谷歌chrome - Javascript程序不工作在Windows 7机器
google chrome - Javascript program not working in Windows 7 machine
我开发了一个Javascript程序,它在Windows 8电脑上运行良好,但在Windows 7上运行不了。
这个程序有一个按钮,允许用户选择一个文件并在文本区显示内容。
该网页在以下版本中进行了测试:
在Windows 7 - Chrome 20.0.1132.47 m和IE7在Windows 8 - Chrome上的20.0.1132.47 m和IE9
可能是因为不同的Windows版本吗?无论如何,通过调整机器配置或程序代码来克服它?如果是由于后者,我愿意附上代码。
谢谢。
这是一个从文件中解密一些文本的程序。按钮允许用户从"打开对话框"中选择文件。选择后,内容将显示在输入文本区。
请忽略下面的"readByLine"answers"readKeyword"模块,因为它们存在一些问题。
不确定Chrome 20.0.1132.47 m和IE7是否支持HTML5。
附加如下代码:
<html>
<head>
<script type="text/javascript">
//Select a Cipher file from Open Dialog Box
function readCipherFile()
{
if (!window.FileReader)
document.getElementById("cipher").innerHTML = "<p>This browser doesn''t support File API</p>";
else
{
// Input handler for cipher text
document.getElementById("cipherfile").onchange = function() {
readFileAsText(this.files[0]);
};
}
}
//Read content as text and display in Input textarea
function readFileAsText(file)
{
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function(event) {
document.getElementById("cipher").innerHTML = event.target.result;
};
reader.onerror = function() {
document.getElementById("cipher").innerHTML = 'Unable to read ' + file.fileName;
};
}
//Select a Keyword file from Open Dialog Box
function readKeyword()
{
if (!window.FileReader)
document.getElementById("keyword").innerHTML = "<p>This browser doesn''t support File API</p>";
else
{
// Input handler for keyword
document.getElementById("keyfile").onchange = function() {
readByLine(this.files[0]);
};
}
}
//Read and display one keyword at a time
function readByLine(file)
{
var reader = new FileReader();
var arr = "";
console.log("test" + arr);
console.log(file);
reader.onload = function(event) {
arr = event.target.result;
};
reader.readAsText(file);
for(i=0; i<arr.length; i++)
{
arr = arr.split("'n");
document.getElementById("keyword").value = arr;
}
//display the next keyword when button is clicked
var keyButton = document.getElementById("keyfile");
keyButton.addEventListener("click", readByLine, false);
}
</script>
</head>
<body>
<center>
<h2>Vigenere Cipher</h2>
<br>
<form name="form1">
<table>
<tr>
<td>
Input:
</td>
<td>
<textarea name=input id="cipher" rows=10 cols=60 wrap=virtual></textarea>
</td>
</tr>
<tr>
<td></td>
<td align="center">
<input type=file id="cipherfile" onClick="readCipherFile(this)" />
</td>
</tr>
<tr height="20px"></tr>
<tr>
<td>
Key:
</td>
<td>
<textarea name=key id="keyword" rows=2 cols=60 wrap=virtual></textarea>
</td>
<tr>
<td></td>
<td align="center">
<input type=file id="keyfile" onClick="readKeyword()" />
</td>
</tr>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<input type=button value="Decrypt" onClick="decode()" style="margin-left: 135px">
</td>
</tr>
<td>
Output:
</td>
<td>
<textarea id="output" rows=10 cols=60 wrap=virtual></textarea>
</td>
</table>
</form>
</center>
</body>
<html>
相关文章:
- 在Windows 10中自动执行例行程序(主要与浏览器交互)
- toLocaleDateString和toLocaleString方法不尊重机器时区
- Windows形成web浏览器控件和Javascript更改的DOM
- Windows 8固定的网站互动程序
- 有没有任何方法可以使用node-js从不同的机器打开浏览器
- 如何添加CSS&JavaScript进入Windows窗体应用程序C#.net
- 将Windows文件路径组织到文件夹中
- Windows Azure通知中心错误
- Windows 8 Javascript应用程序XML对象
- Windows.Open 在 window.Location 工作时不起作用
- 在JavaScript Windows 8应用程序中设置桌面壁纸
- 为什么我的windows机器上的chrome限制了脚本中的frequencybin数量
- 为什么在Windows机器上吞咽这么慢
- 在 Windows 8 机器上安装 Cairo 和 Canvas
- 在windows机器上,完整日历不能在FF中工作
- 如何了解Windows XP或7机器是否使用PHP打开或关闭
- 单核Windows 7机器上的Node.js电子应用程序在文件I/O上很慢
- 在windows机器上安装expressjs时出现错误
- 来自Windows机器的date对象——时区问题
- 谷歌chrome - Javascript程序不工作在Windows 7机器