Javascript inside LD JSON -
i'm wondering if it's possible execute javascript inside ld+json script. example "window.location.hostname"
<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "website", "url": "http://" + window.location.hostname } </script>
no, scripts of type "application/ld+json" won't executed. but, this:
<script> var el = document.createelement('script'); el.type = 'application/ld+json'; el.text = json.stringify({ "@context": "http://schema.org", "@type": "website", "url": "http://" + window.location.hostname }); document.queryselector('body').appendchild(el); </script>
Comments
Post a Comment