Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I combine an anchor tag AND a passed variable in an HTML HREF?

Tags:

html

href

anchor

Say I have an anchor somewhere on a different page:

<A NAME="blah"> 

On the page I'm currently on, I want to go that that anchor on that different page while also passing a GET parameter, such as, for example:

<A HREF="otherpage.htm#blah?data=1234">Good Stuff!</A> 

This doesn't seem to be working for me. It loads the page and passes the variable but doesn't go to the anchor. I've searched for examples on the anchor tag, and there's tons of them, but nobody talks about jumping to an anchor in a page while also passing parameters in the URL.

like image 995
Fredashay Avatar asked Apr 14 '12 23:04

Fredashay


People also ask

Can I pass value in anchor tag?

The only way to pass data with an anchor tag is to put them in the query string. If you have a lot of data and don't want it to appear in the address window, why do you want to use an anchor tag? You could always submit a form from the onclick event of an anchor tag.

How do you pass a HREF variable in HTML?

href”, append the variable to it (Here we have used a variable named “XYZ”). Then we need to append the value to the URL. Now our URL is ready with the variable and its value appended to it. In the example below, we will append a variable named 'XYZ' and its value is 55.

Can I use two HREF in anchor tag?

You can't have a link go to two places, but you can have it go to a php script that redirects to the second page when it's done doing whatever you need it to do.

Which tag is used to define both hyperlink and anchor?

The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.


1 Answers

The bookmark always goes last.

<A HREF="otherpage.htm?data=1234#blah">Good Stuff!</A> 
like image 108
Randy the Dev Avatar answered Sep 24 '22 01:09

Randy the Dev