Sunday, 15 March 2015

javascript - window location href for image -



javascript - window location href for image -

trying add together share button image , configuration in javascript this:

url: window.location.href

i want url url image , not entire page. here config

this.config = { enabled_networks: 0, protocol: ['http', 'https'].indexof(window.location.href.split(':')[0]) === -1 ? 'https://' : '//', url: window.location.href, caption: null, title: (content = document.queryselector('meta[property="og:title"]') || document.queryselector('meta[name="twitter:title"]')) ? content.getattribute('content') : (content = document.queryselector('title')) ? content.innertext : void 0, image: (content = document.queryselector('meta[property="og:image"]') || document.queryselector('meta[name="twitter:image"]')) ? content.getattribute('content') : void 0, description: (content = document.queryselector('meta[property="og:description"]') || document.queryselector('meta[name="twitter:description"]') || document.queryselector('meta[name="description"]')) ? content.getattribute('content') : '',

can tell me how target image url instead of entire page?

try this:

url: $("yourimageselector").prop("src")

this grab image dom, , grab value of src attribute, url of image (note method convert url absolute url you).

javascript jquery

No comments:

Post a Comment