1

I use Google Table Charts in my "normal" (NON-AMP) pages. But in the AMP pages they are not there. When I load my page without /AMP at the end I can see the tables and with /AMP at the end not.
Example:
https://lotto-6-aus-49.de/lottozahlen-von-heute-mittwoch-den-20-03-2019 and
https://lotto-6-aus-49.de/lottozahlen-von-heute-mittwoch-den-20-03-2019/amp
To get AMP pages on my site I use a wordpress plugin. I searched for adding "java scripts" in AMP site but cannot find. Can someone help me?

2 Answers 2

0

First of all you need a template with your charts. Let's call that template.html

<amp-iframe width="200" height="100"
sandbox="allow-scripts allow-same-origin"
layout="responsive"
frameborder="0"
src="/template.html"></amp-iframe>

You can put all of your js into that template. The iFrame should work. But please keep in mind that iFrames are only allowed when below 80% from the top of the page.

if you need to load dynamic content, you could create a php file which accepts parameters and returns a html file that does include the chart.

<amp-iframe width="200" height="100"
sandbox="allow-scripts allow-same-origin"
layout="responsive"
frameborder="0"
src="/charts.php?startDate=2019-01-01&endDate=2019-02-01"></amp-iframe>
0

Actually you can't. You need JavaScript for that which doesn't work with AMP.

added:

iFrame Solution: First you create a template (html + js) that does show the chart you want to display. Then you import that template file using amp-iframe.

<amp-iframe width="200" height="100"
sandbox="allow-scripts allow-same-origin"
layout="responsive"
frameborder="0"
src="pathtotemplate/template.html">
</amp-iframe>
3
  • Thanks for the answer. I was not sure about that. Now I know. Mar 26, 2019 at 18:09
  • You could try using an iFrame - and load the charts via iFrame Apr 1, 2019 at 16:15
  • Hi, thanks for the reply. Can you please tell me how? Apr 3, 2019 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.