【问题标题】:Find metatags in body with javascript in Mozilla Firefox在 Mozilla Firefox 中使用 javascript 在正文中查找元标记
【发布时间】:2011-03-07 18:33:30
【问题描述】:

如何在 Mozilla Firefox 的正文部分找到元标记?

例子:

<!DOCTYPE html>
    <head profile="http://microformats.org/profile/hcalendar"></head>
    <body>
    <div itemscope itemtype="http://data-vocabulary.org/Event">
        <a href="http://www.example.com/events/spinaltap" itemprop="url" ><span itemprop="summary">Spinal Tap</span></a>
        <img itemprop="photo" src="spinal_tap.jpg" />
        <span itemprop="description">After their highly-publicized search for a new drummer,Spinal Tap kicks off their latest comeback tour with a SanFrancisco show.</span>
        When:
        <time itemprop="startDate" datetime="2015-10-15T19:00-08:00">Oct 15, 7:00PM</time>—
        <time itemprop="endDate" datetime="2015-10-15T19:00-08:00">Oct 15, 9:00PM</time>
        Where:
        <span itemprop="location" itemscope itemtype="http://data-vocabulary.org/?Organization">
            <span itemprop="name">Warfield Theatre</span>
            <span itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">
                <span itemprop="street-address">982 Market St</span>, 
                <span itemprop="locality">San Francisco</span>, 
                <span itemprop="region">CA</span>
            </span>
            <span itemprop="geo" itemscope itemtype="http://data-vocabulary.org/?Geo">
                <meta itemprop="latitude" content="35.774929"/>
                <meta itemprop="longitude" content="-122.419416"/>
            </span>
        </span>
        Category: <span itemprop="eventType">Concert</span> 
    </div>
    </body>
</html>

似乎 Firefox 正在将元标记移动到头部,使它们无法作为 itemprop="geo" 的子元素访问。有没有比通过标签名称获取 lat/lng 元标签,然后将它们与 itemtype="Event" 一起拼图更好的方法?

【问题讨论】:

  • 为什么你的文档中间会有元标记?
  • 在 HTML5 中,您可以在任何地方使用 元素。在此示例中,它正在注释不可见的数据。
  • 在这种情况下,您的文档只能在 HTML5 浏览器中使用,因此您必须等待 Firefox 4。

标签: javascript firefox mozilla meta-tags microdata


【解决方案1】:

如果我阅读了 Bug 591467 "Implement HTML Microdata API"the release notes of Firefox 16.0 这应该从 Firefox 16 开始支持。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-11
    • 2013-08-08
    • 1970-01-01
    • 1970-01-01
    • 2011-02-16
    • 1970-01-01
    相关资源
    最近更新 更多