0

I was wondering if it's possible to reference the value of an html element through a URL parameter?

A use case for this would be if I want to link to something another website was linking to, like a google drive or drop box download link. By embedding a link within a link like this I can send someone a download link with some inherent sense of trust that it's not malicious if the recipient now knows the download link was posted by the owner of a specific website.

There could be more uses for this as well but that's my particular use case right now.

Haven't been able to find a way to do this yet, and actually don't think this possible, but wanted to double check by asking here first.

I know you can reference a particular spot on a page by using the hashtag sign at the end of a url, like this https://something.com/#element-name-x

So what I guess I'm looking for is something like if an <a> tag has an id/name of "where-to" and an href value of "wherever.com" I'd be looking to do something like <a href="https://somethingelse.com/#where-to{href}">Click the Link</a>, where clicking "Click the Link" at something.com wouldn't take you to somethingelse.com#where-to but it would go directly to wherever.com

5
  • I shouldn't have posted this at 2am, making this comment to bump it up now that we're in usual working hours in the western hemisphere Commented Oct 3, 2023 at 15:46
  • Well I think I thought of a workaround but it seems janky and not very ellegent. If I have some Javascript running on the intermediate page looking for a query string parameter that gives the id of some html element that is either an <a> tag or has a child <a> element. If parameter is found query that <a> tag's href value and run window.location.replace("href_value") to redirect to the end destination without further input from the user. Commented Oct 3, 2023 at 23:06
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Oct 4, 2023 at 10:11
  • I'm not sure how to make it more clear but how about this. Link Y exists on y.com, I want to share Y with someone but retain the assurances I'm not sending a malicious link by showing the link I'm sending exists on y.com. Rather than have the person I'm trying to share Y with personally navigate to y.com first, then find Y and click on it, I'd like to have a shareable link for y.com that has some sort of parameter that locates Y and auto redirects to Y without actually loading y.com Commented Oct 4, 2023 at 14:37
  • @AustinFoss, you might find stackoverflow.com/q/47648399/9731176 and stackoverflow.com/q/56365830/9731176 useful. Commented Jun 13, 2024 at 23:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.