This is my first post and I'm not very good with Java. I'm trying to automatically create the following schema meta tag for my website:
<meta itemprop="url" content="URLofthispage" />
The best I came up (pieced together from the internet) with is:
<script>var addLink = function(url){
var link = document.createElement('meta');
link.setAttribute('itemprop', 'url');
link.content = window.location.href;
document.getElementsByID('placehere')[0].appendChild(link);
</script>
And then <p id="placehere"><p> to place the meta tag in the correct location in my code.
I have tried the same format also for <link itemprop="url" href="URLofthispage" /> which can also be used for the url tag.
Any suggestions would be greatly appreciated.