Questions tagged [href]

Hyperlink (or link) is a reference to a document that the reader can directly follow, or that is followed automatically.

Hyperlink (or link) is a reference to a document that the reader can directly follow, or that is followed automatically.

A hyperlink points to a whole document or to a specific element within a document. Hypertext is text with hyperlinks. A software system for viewing and creating hypertext is a hypertext system, and to create a hyperlink is to hyperlink (or simply to link). A user following hyperlinks is said to navigate or browse the hypertext.

A hyperlink has an anchor, which is the location within a document from which the hyperlink can be followed; the document containing a hyperlink is known as its source document. The target of a hyperlink is the document, or location within a document, to which the hyperlink leads. Users can activate and follow the link when its anchor is shown, usually by touching or clicking on the anchor with a pointing device. Following the link has the effect of displaying its target, often with its context.

Links are specified in HTML using the (anchor) elements. To see the HTML used to create a page, most browsers offer a "view page source" option. Included in the HTML code will be an expression in the form symbol "," marking the start of an anchor, followed by the highlighted text and the "" symbol, which indicates the end of the source anchor. The element can also be used to indicate the target of a link.

http://en.wikipedia.org/wiki/Hyperlink

5033 questions
149
votes
6 answers

anchor jumping by using javascript

I have a question that will be found very often. The problem is that nowhere can be found an explicit solution. I have two problems regarding anchors. The main goal should be to get a nice clean url without any hashes in it while using anchors to…
bonny
  • 3,147
  • 11
  • 41
  • 61
125
votes
10 answers

How to test anchor's href with react-testing-library

I am trying to test my anchor tag. Once I click it, I want to see if the window.location.href is what I expect. I've tried to render the anchor, click it, and then test window.location.href: test('should navigate to ... when link is clicked', () =>…
jaypee
  • 1,757
  • 3
  • 9
  • 12
123
votes
16 answers

How to disable anchor "jump" when loading a page?

I think this may not be possible, will try and explain as best as I can. I have a page containing tabs (jquery powered), controlled by the following: I'm using this code, as provided by another user from a previous question.
Ross
  • 18,117
  • 7
  • 44
  • 64
121
votes
10 answers

How can I disable HREF if onclick is executed?

I have an anchor with both HREF and ONCLICK attributes set. If clicked and Javascript is enabled, I want it to only execute ONCLICK and ignore HREF. Likewise, if Javascript is disabled or unsupported, I want it to follow the HREF URL and ignore…
Ky -
  • 30,724
  • 51
  • 192
  • 308
111
votes
17 answers

Most robust method for showing Icon next to text

There are different ways to show graphics in a page next to text. I need to include a graphic/icon that indicates a new tab will be opened. I know it's possible to do using at least these different methods: Unicode character from default…
Lee Englestone
  • 4,545
  • 13
  • 51
  • 85
105
votes
8 answers

ASP MVC href to a controller/view

I have this:
  • Clients
  • Which works fine. But if I am already on this page or on the controller e.g. /Users/Details and I click on this link it redirects me to /Users/Index. How can I…
    Zapnologica
    • 22,170
    • 44
    • 158
    • 253
    87
    votes
    7 answers

    What is the difference between the different methods of putting JavaScript code in an ?

    I have seen the following methods of putting JavaScript code in an tag: function DoSomething() { ... return false; } link link
    Darryl Hein
    • 142,451
    • 95
    • 218
    • 261
    78
    votes
    7 answers

    Stop link from sending referrer to destination

    I have a page where I don't want the outbound links to send a referrer so the destination site doesn't know where they came from. I'm guessing this isn't possible but I just want to make sure there weren't any hidden javascript magic that could do…
    nolanpro
    • 2,257
    • 3
    • 23
    • 23
    76
    votes
    17 answers

    Test if links are external with jQuery / javascript?

    How do I test to see if links are external or internal? Please note: I cannot hard code the local domain. I cannot test for "http". I could just as easily be linking to my own site with an http absolute link. I want to use jQuery / javascript, not…
    Matrym
    • 16,643
    • 33
    • 95
    • 140
    71
    votes
    1 answer

    Removing underline with href attribute

    Possible Duplicate: How to remove the underline for anchors(links)? In the following code below, the link gets underlined when I use the href attribute. goto this link I want the link to be…
    Victor Mukherjee
    • 10,487
    • 16
    • 54
    • 97
    70
    votes
    8 answers

    jQuery: go to URL with target="_blank"

    I am using this bit of jQuery code to get href of the link: var url = $(this).attr('href'); -- and this bit of code to go to that href: window.location = url; Everything is just the way I want it, except the new page opens in the same window as…
    Dimitri Vorontzov
    • 7,834
    • 12
    • 48
    • 76
    68
    votes
    2 answers

    Open Google map with specific address in a browser

    What is the url structure to search for an address in Google Maps? I want to offer an address on my website that, when clicked, it will open google maps directly to an address from my script. I want to create a link which will…
    URL87
    • 10,667
    • 35
    • 107
    • 174
    66
    votes
    13 answers

    Make anchor links refer to the current page when using

    When I use the HTML tag to define a base URL for all relative links on a page, anchor links also refer directly to the base URL. Is there a way to set the base URL that would still allow anchor links to refer to the currently open page? For…
    Chris Down
    • 1,590
    • 1
    • 14
    • 25
    66
    votes
    2 answers

    JavaScript getElement by href?

    I've got the script below var els = document.getElementsByTagName("a"); for(var i = 0, l = els.length; i < l; i++) { var el = els[i]; el.innerHTML = el.innerHTML.replace(/link1/gi, 'dead link'); } However this searches through the page and…
    owenmelbz
    • 6,180
    • 16
    • 63
    • 113
    64
    votes
    4 answers

    How to get "raw" href contents in JavaScript

    I am trying to write a GreaseMonkey script in which I want to find all of the links that are relative links. It seemed to me that the way to do that would be to match the contents of href against /^https?:///. But I find that when I access the…
    wfaulk
    • 1,765
    • 1
    • 17
    • 24