HREF=“” automatically adds to current page URL (in PHP). Can't figure it out

前端 未结 8 957
借酒劲吻你
借酒劲吻你 2020-12-01 11:48

Longtime reader of stackoverflow but first question.

I\'m working with Wordpress (specifically thesis theme) in the custom_functions.php file and am finding for some

8条回答
  •  时光取名叫无心
    2020-12-01 12:50

    This is how a browser interprets and empty href. It assumes you want to link back to the page that you are on. This is the same as if you dont assign an action to a

    element.

    If you add any word in the href it will append it to the current page unless you:

    • Add a slash / to the front of it telling it to append it to your base url e.g. http://www.whatever.com/something
    • add a # sign in which case it is an in-page anchor
    • or a valid URL

    EDIT: It was suggested that I add a link to help clarify the situation. I found the following site that I think does a really good job explaining the href attribute of anchor tags and how it interprets URL paths. It is not incredibly technical and very human-readable. It uses lots of examples to illustrate the differences between the path types: http://www.mediacollege.com/internet/html/hyperlinks.html

提交回复
热议问题