我知道有很多关于iframe代码的问题。但我仍然无法从其他问题中得到任何帮助。我想从World Counts
插入一些计数器。但是他们提供的代码似乎有问题,或者Blogger不接受它的编写方式。
主要问题是
- 对实体“颜色”的引用必须以';'结尾分隔符
- 实体“颜色”被引用,但未声明。
font_family, font_size and token
也是如此。
我加了';'需要的地方并声明实体颜色=白色到颜色=白色&
<iframe height='100' src='http://www.theworldcounts.com/counters/ocean_ecosystem_facts/coral_reef_destruction_facts/embed?background_color=white&color=black&font_family=%22Helvetica+Neue%22%2C+Arial%2C+sans-serif&font_size=14&token=ccfd8c44a4686cada3a2e343f1d56a9b98ac49d4' style='border: none' width='300'></iframe>
即使在更正后Blogger接受了代码,但计数器根本没有出现在网站上。
问题是由iframe标签的&
链接中的src
符号引起的。您需要通过将其替换为&
来使其逃脱,以使iframe标记被Blogger的XML解析器接受。此外,切换到HTTPS协议将确保不会发生mixed content
错误
<iframe height='100' src='https://www.theworldcounts.com/counters/ocean_ecosystem_facts/coral_reef_destruction_facts/embed?background_color=white&color=black&font_family=%22Helvetica+Neue%22%2C+Arial%2C+sans-serif&font_size=14&token=ccfd8c44a4686cada3a2e343f1d56a9b98ac49d4' style='border: none' width='300'></iframe>