Answer the question
In order to leave comments, you need to log in
How to get the value of photo_100 into a function?
You need to get the value data.response[0].photo_100
into the function function share_app()
for it to work like this
var w = window.open('https://vk.com/share.php?url=https://vk.com/app111111_-{id_cook}&title=Приложение сообщества {group_name}&image=' + data.response[0].photo_100, '', 'scrollbars=1');
var strGET = window.location.search.replace( '?', '');
var params = window
.location
.search
.replace('?','')
.split('&')
.reduce(
function(p,e){
var a = e.split('=');
p[ decodeURIComponent(a[0])] = decodeURIComponent(a[1]);
return p;
},
{
}
);
var verapi = '5.78';
VK.api("groups.getById", {
"group_ids": params['group_id'], "v": verapi
}, function (data) {
document.getElementById('group_name').innerHTML = data.response[0].name;
var img = document.getElementById("group_photo"); img.src = data.response[0].photo_100;
var share_photo = data.response[0].photo_100;
});
function share_app() {
var w = window.open('https://vk.com/share.php?url=https://vk.com/app111_-{id_cook}&title=Приложение сообщества {group_name}&image=' + share_photo , '', 'scrollbars=1');
w.onload = function() {
var z = this.document.getElementById("target");
}
}
share_photo
into function to work
Answer the question
In order to leave comments, you need to log in
Try moving the share_photo declaration outside of the function (from VK.api ):
var verapi = '5.78';
var share_photo;
VK.api("groups.getById", {
"group_ids": params['group_id'], "v": verapi
}, function (data) {
document.getElementById('group_name').innerHTML = data.response[0].name;
var img = document.getElementById("group_photo"); img.src = data.response[0].photo_100;
// убираем var
share_photo = data.response[0].photo_100;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question