• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Determining which href tag to show based on if JS is enabled or not

I have a problem where I have to loop through a set of photos and generate <a href> tags for each one that is displayed. However, the link that is displayed is going to depend on whether or not javascript is enabled. So I'm trying to figure out which way to make this happen is the best practice.

My first thought is to simply declare the <a href> as I would if JS wasn't enabled (as well as include an id in the tag) and then write some JS that swaps the a href tag for the JS enabled one. Any body have any better ideas?
 
In theory you could do something to figure out if javascript was enabled, remember that server-side, and generate the appropriate links server-side from that point forward. It's an awful idea for a handful of reasons, but just throwing it out there.
 
Back
Top