Answer the question
In order to leave comments, you need to log in
Anonymous function does not work in onAuth(Authorization Widget from VK)?
I made an authorization widget for an empty site on a local server ( https://vk.com/dev/Login?aid=6418856&mode=2).
Without changing anything copy-pasted their suggested embed code
<script type="text/javascript" src="//vk.com/js/api/openapi.js?152"></script>
<script type="text/javascript">
VK.init({apiId: 6418856});
</script>
<!-- VK Widget -->
<div id="vk_auth"></div>
<script type="text/javascript">
VK.Widgets.Auth("vk_auth", {"onAuth":"function(data) {alert('user '+data['uid']+' authorized');}"});
</script>
if (options.onAuth) {
options.onAuth(data);
}
VK.Widgets.Auth("vk_auth", {"onAuth":alert(1)});
then everything works fine. Answer the question
In order to leave comments, you need to log in
UPD: I fiddled with this problem for two hours. It turned out that in the line
Quotes are not needed after the onAuth parameter, i.e. just like this:
Why VK does not give a working example is a question.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question