Questions tagged [location-href]

JavaScript run in a browser has access to both the Document.location and Window.location which has a href property containing the whole URL associated with the content.

JavaScript run in a browser has access to both the Document.location and Window.location which has a href property containing the whole URL associated with the content.

References

177 questions
2
votes
2 answers

Getting values from location

I need to get the search query from the search query of the address of the page. What is the safest cross-browser, and most efficient method of getting the string. for…
tcooc
  • 20,629
  • 3
  • 39
  • 57
2
votes
1 answer

Disable the base href for just one link

I have a website, which uses base href tag. But I want to use just one element with the absoulute path. Is it possible to make an exception for it? Is there maybe any trick? Because for some reasons I can not remove the tag, but I have to use an…
Andrej Tihonov
  • 649
  • 2
  • 9
  • 21
2
votes
3 answers

Use Javascript onClick Event to go to href of a child element

Due some weirdness I'm stuck with using javascript to Jquery to get a link to work by clicking the a parent li element. Basically clicking anywhere on the li should take the user to the link of the a that is a direct child of it. What I have some…
Epleroma
  • 153
  • 6
  • 15
2
votes
2 answers

how to move href using javascript

sorry for my english. Using jquery, i want pressing keyboard arrow key to redirect to an url with href(#g) tag I mean if downkey is pressed, how to move to #g ? Javascript : $(function(e){ $(e.witch==38) move #g //how to that? not use…
joshua.kim
  • 373
  • 3
  • 11
2
votes
1 answer

`window.location.href` is just refreshing the page

This is kind of confusing, but I'll try to explain it as well as I can. I have 4 select menus laid directly on top of each other with absolute positioning. At any one time, three of them are invisible (with display: none;) while 1 of them is visible…
Ian
  • 5,704
  • 6
  • 40
  • 72
2
votes
3 answers

location.href to a link without http://

I have a webpage - http://www.example.com/ - where I have a button. On click of the button I need to go to a particular link (www.google.com). The button is like :
Riju Mahna
  • 6,718
  • 12
  • 52
  • 91
1
vote
2 answers

JavaScript code not working in Safari

I have three pages: Step1.php -> step2.php -> step3.php As it shows, after submitting the step1.php it will go to step2.php In step2.php there is JavaScript on the bottom, and it will automatically redirect to step3.php after 2 seconds.
Linto
  • 1,234
  • 3
  • 25
  • 41
1
vote
1 answer

top.document.location.href property behaviour in IE(8/9)

I have a piece of code which works in a way that is unexpected to me. Let me first put down the details, so the code looks more or less like this: window.onunload = doUnload; var unLoadTimer; var gInvokeOnBeforeUnload = true; function…
guesXy
  • 50
  • 1
  • 6
1
vote
0 answers

location.href doesn't work properly in wkwebview

I am receiving url from webview through location.href. However, if location.href is called consecutively on one page, the last location.href is called and the first location.href is missing. Both are called well on Android, but is there a reason for…
kyeahen
  • 161
  • 8
1
vote
0 answers

window.location.href updates only after the test is done in react

I use useNavigate from react-router-dom to handle navigation. I called a useNavigate hook at the top level of the functional component like that: const navigate = useNavigate(). Inside a handleClick() function I use it to navigate to an another page…
ptjr
  • 11
  • 2
1
vote
1 answer

Duplicate pathname issue in useLocation

I'm making a web with react and react router. The problem is, the pathname in useLocation() has a record of the previous page and a record of the current page. For example, '/' on the home screen and the '/business' page on another page are…
rudenick
  • 154
  • 1
  • 1
  • 10
1
vote
1 answer

Javascript window.location.href and window.alert

How can Javascript window.location.href and window.alert can work together inside if else cycle? I have the following code to insert data inside an SQL table. If something wrong, a notice message appear (Notice: Undefined variable: code1 in......)…
Massimo D. N.
  • 316
  • 1
  • 6
  • 17
1
vote
2 answers

window.location.href inside of button copy it

Please help me with extracting window.location.href from a button .... click function doesn't work... just sends me to the main page and does nothing... I want to find it inside of an iframe why there is (#xx)
1
vote
2 answers

location.reload in addEventListener

I'm trying to make the document reload when a button is clicked. Here's my code: var e = document.getElementById('a'); e.addEventListener('click',location.reload); It returns Uncaught TypeError: Illegal Invocation after e was clicked. However, the…
jeqcho
  • 19
  • 1
  • 1
  • 6
1
vote
2 answers

window.location.hash always returns the previous and not the current hash

so I made a mapped image in html/css/javascript. I made it so when I click on an area a function get's called that makes a modal appear, the content depends on the location.hash that changes due to the href attribute in the mapped areas. The thing…
kurganon
  • 11
  • 3
1 2
3
11 12