Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
ppk 🇪🇺
@ppk@front-end.social  ·  activity timestamp 2 months ago

onDomContentLoaded, Firefox recognises document.querySelector(':target'). Chrome and Safari do not.

  • Copy link
  • Flag this post
  • Block
ppk 🇪🇺
@ppk@front-end.social replied  ·  activity timestamp 2 months ago

That is, if the page has a hash like #id, Firefox knows the target element onDomContentLoaded, but Chrome and Safari don't.

Annoying. There goes my nice simple idea for hawking more conference tickets.

  • Copy link
  • Flag this comment
  • Block
Christopher Kirk-Nielsen
@chriskirknielsen@front-end.social replied  ·  activity timestamp 2 months ago
@ppk That's annoying. Would `document.querySelector(window.location.hash)` do the trick instead?
  • Copy link
  • Flag this comment
  • Block
ppk 🇪🇺
@ppk@front-end.social replied  ·  activity timestamp 2 months ago
@chriskirknielsen It does! Thanks!
  • Copy link
  • Flag this comment
  • Block
Christopher Kirk-Nielsen
@chriskirknielsen@front-end.social replied  ·  activity timestamp 2 months ago
@ppk Sweet! Chrome seems happy returning `null` with an empty hash, but Firefox is not, just FYI — might be good to wrap a try/catch on that one.
  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.21 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login