Jump to content
BadCoder

dynamic itemprop URL for Schema Mircodata

Recommended Posts

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...