How to get “raw” href contents in JavaScript

前端 未结 3 1781
孤独总比滥情好
孤独总比滥情好 2020-11-27 19:06

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 c

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 19:58

    Typical. I figured it out myself almost immediately after posting the question.

    instead of:

    anchor.href
    

    use:

    anchor.getAttribute("href")
    

    Of course, it took me longer to type in this answer than it took everyone else to answer it. (Damn, you people are fast.)

提交回复
热议问题