Firefox与IE元素检查器差异:元素ID缺失问题咨询
Great question—this is a classic cross-browser quirk tied to how older browsers and legacy scripts behave. Let’s break this down clearly:
First: Yes, that ID is IE-specific (dynamically generated)
The wb-auto-12 ID you see in IE isn’t part of the page’s original HTML. Looking at the class names like wb-init and wb-details-inited, this element is part of the Government of Canada’s Web Experience Toolkit (WET) — a framework they use for their sites. Older versions of WET included fallback logic that dynamically added IDs to interactive components only in IE (to work around IE’s limited support for modern HTML features like <summary>/<details>).
In Firefox (and other modern browsers), this IE-specific fallback doesn’t run, so the ID never gets created. That means there’s no way to "get" this ID in Firefox—it simply doesn’t exist in that environment.
Cross-Browser Ways to Locate the Element
Instead of relying on the IE-only ID, use these reliable, consistent methods to target the button across both browsers:
- CSS Selector with Classes: Combine the element type and its stable, original classes:
This works everywhere because the classes are part of the page’s core code.summary.btn.btn-default.text-center - XPath by Text Content: Target the element directly using its visible text (use
normalize-spaceto handle any hidden whitespace)://summary[normalize-space(text())='Report a problem or mistake on this page'] - Narrow with Parent Context: If there are similar elements on the page, add a parent selector to be more precise (this button lives in the page footer):
footer summary.btn.btn-default.text-center
All these approaches will work seamlessly across IE and Firefox, so you won’t have to depend on browser-specific dynamic IDs anymore.
内容的提问来源于stack exchange,提问作者Melodie Gauthier

