Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.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将字符串写入文本文件_Javascript_Html_Text Files_Activexobject - Fatal编程技术网

使用Javascript将字符串写入文本文件

使用Javascript将字符串写入文本文件,javascript,html,text-files,activexobject,Javascript,Html,Text Files,Activexobject,我们正在尝试将存储在字符串中的URL保存到文本文件中,但似乎无法使其正常工作。它不会保存到文件中,尽管我们的测试表明该函数在应该运行的时候实际上正在运行 代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <button onclick="instagramclick()">Login to instagram<

我们正在尝试将存储在字符串中的URL保存到文本文件中,但似乎无法使其正常工作。它不会保存到文件中,尽管我们的测试表明该函数在应该运行的时候实际上正在运行

代码如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>

<button onclick="instagramclick()">Login to instagram</button>
<button onclick="myFunction()">Test Button</button>

<script>

function myFunction() {
    alert("Hello World");
}

function instagramclick(){
    alert("button clicked");
    window.location.href = "https://instagram.com/oauth/authorize/?client_id=8a612cd650344523808233c0468c80ed&redirect_uri=http://u-ahmed.github.io/HookedUp/instagram.html&response_type=token";
}

function WriteDemo(link)
{
 var fso, f, r;
 var ForReading = 1, ForWriting = 2;
 fso = new ActiveXObject("Scripting.FileSystemObject");
 f = fso.OpenTextFile("database.txt", ForWriting, true);
 f.Write(link);
 f.Close();
 r = f.ReadLine();
return(r);
}

window.onload = function writedamnyou(){
var token = window.location.href.substring(62);
if (token != ""){
    // document.write(token);
    var link = "https://api.instagram.com/v1/users/self/feed?access_token=" + token;
    // w = window.open('database.txt')
    WriteDemo(link);
  // document.write(stuff);


}
};

</script>
<p id="no"></p>
</body>
</html>

登录instagram
测试按钮
函数myFunction(){
警报(“你好世界”);
}
函数instagramclick(){
警报(“点击按钮”);
window.location.href=”https://instagram.com/oauth/authorize/?client_id=8a612cd650344523808233c0468c80ed&redirect_uri=http://u-ahmed.github.io/HookedUp/instagram.html&response_type=token”;
}
函数WriteDemo(链接)
{
风险值fso,f,r;
变量ForReading=1,ForWriting=2;
fso=新的ActiveXObject(“Scripting.FileSystemObject”);
f=fso.OpenTextFile(“database.txt”,用于写入,true);
f、 写入(链接);
f、 Close();
r=f.ReadLine();
回报率(r);
}
window.onload=函数writedanyou(){
var token=window.location.href.substring(62);
如果(令牌!=“”){
//文件。写入(令牌);
变量链接=”https://api.instagram.com/v1/users/self/feed?access_token=“+代币;
//w=window.open('database.txt')
WriteDemo(链接);
//文件。写(东西);
}
};


提前感谢。

您正在测试哪个浏览器?这是在chrome中运行的。chrome不再支持activex,请改用internet explorer。如果你要在chrome中使用你的应用程序,这种方法对你没有帮助,请尝试本机消息你正在测试哪个浏览器?这是在chrome中运行的。chrome不再支持activex,请改用internet explorer。如果你想在chrome中使用你的应用程序,这个方法对你没有帮助,试试原生消息