: JS call gives me a text value instead of an HTML link for Microdata property I am trying to extract the book URL from a link using Microdata. The format is specified in Schema.org. Here
I am trying to extract the book URL from a link using Microdata. The format is specified in Schema.org.
Here is my HTML:
<div class="col-sm-4 col-md-3" itemscope itemtype="http://schema.org/Book">
<div class="thumbnail">
<img src="{{ book.thumbnailurl }}" itemprop="thumbnailUrl" style="width: 100px;height: 200px;">
<div class="caption">
<h4><span itemprop="name">{{ book.name }}</span> - <span itemprop="author">{{ book.author }}</span></h4>
<p><span itemprop="about"> {{ book.about }}</span></p>
<p>
<a href="{{ book.url }}" itemprop="url" onclick="trackOutboundLink(‘{{ book.name }}’);">
<button type="button" class="btn btn-default btn-md">
<span class="glyphicon glyphicon-book"></span>Read
</button>
</a>
</p>
</div>
</div>
</div>
When I use Google's snippet testing tool the JSON API returns book as an HTML link. However when I make the call in JavaScript the value of url is text("Read").
What am I missing?
More posts by @Gloria169
1 Comments
Sorted by latest first Latest Oldest Best
Ok finally after a lot of digging, I have the answer.
The root cause is as follows:
The Google CSE(Custom Search Engine) is not consuming the microdata property value as the href attribute of the "a" HTML element. It is consuming the child text content on the "a" HTML element.
The Google CSE is able to consume the href from a "link" HTML element.
Therefore.
<a href="{{ book.url }}" itemprop="url" onclick="trackOutboundLink(‘{{ book.name }}’);">
will not work.
<link itemprop="url" href="{{ book.url }}">
<a href="{{ book.url }}" onclick="trackOutboundLink(‘{{ book.name }}’);">
works.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.