Reputation: 89
We are trying to call a function on a button click, but for some reason the button will not call the function. Can anyone tell us why?
<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/&response_type=token";
var token = window.location.href.substring(43);
if(token="s_denied&error_reason=user_denied&error_description=The+user+denied+your+request"){
alert("That's fine, but we can't access your instagram without your permission.");
}
else {
jQuery(function($) {
function writeToFile(token){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.OpenTextFile("D:\\instagramtoken.txt");
fh.WriteLine(", ,"+ token);
fh.Close();
}
});
}
</script>
</body>
Upvotes: 1
Views: 62
Reputation: 11
You are missing the close braces on your instagramclick() function.
Upvotes: 0
Reputation: 1102
Closing bracket of instagramclick functionn is missing thats why click event is not firing
Upvotes: 0
Reputation: 14746
Try it this will helps you. There was a syntax mistake in the function.
<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/&response_type=token";
var token = window.location.href.substring(43);
if (token = "s_denied&error_reason=user_denied&error_description=The+user+denied+your+request") {
alert("That's fine, but we can't access your instagram without your permission.");
} else {
jQuery(function($) {
function writeToFile(token) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.OpenTextFile("D:\\instagramtoken.txt");
fh.WriteLine(", ," + token);
fh.Close();
}
});
}
}
</script>
</body>
Upvotes: 1