Created
March 22, 2019 21:26
-
-
Save joeworkman/96d161e8b5761b72d6a461e96f8995c4 to your computer and use it in GitHub Desktop.
This will get the property name of meta tag and it will take that value and set the input value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMeta(metaName) { | |
const metas = document.getElementsByTagName('meta'); | |
for (let i = 0; i < metas.length; i++) { | |
if (metas[i].getAttribute('property') === metaName) { | |
return metas[i].getAttribute('content'); | |
} | |
} | |
return ''; | |
} | |
document.querySelectorAll('input[name=text]')[0].value = getMeta("og:title"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment