Questions tagged [window.location]

window.location is a property in JavaScript for getting the current page's location.

671 questions
8
votes
1 answer

NS_BINDING_ABORTED Javascript window.location.replace()

I'm writing some Javascript code and I'm trying to change the current page as the result of the user clicking a button. I'm using this snippet of code: window.location.replace("/customer/order/12"); containing the relative URL within my site that I…
writes_on
  • 1,735
  • 2
  • 22
  • 35
8
votes
1 answer

window.onbeforeunload and window.location.href in IE

We are using window.location.href to navigate the user to a page. Also, we have configured the window.onbeforeunload event to alert users in case there are any unsaved changes. window.onbeforeunload = confirmBeforeClose; function…
Zuber
  • 577
  • 1
  • 11
  • 29
8
votes
1 answer

Firefox window.parent.location

I've a Html page index.htm which has an iframe to page search.htm the search.htm has code like this function executeSearch() { window.parent.location = "/SearchResults.aspx?t=" + txt_Search.value; } this code executed now from…
Mustafa Magdy
  • 1,230
  • 5
  • 28
  • 44
8
votes
1 answer

Is there any difference with using only location vs using window.location across browsers

I find myself always writing: console.log(window.location.href); without even thinking about it. The majority of answers on SO also write it this way. Is there any reason why I can't just write: location.href since location is an object at window…
CodingIntrigue
  • 75,930
  • 30
  • 170
  • 176
7
votes
5 answers

How to change window.location.href in JavaScript and then execute more JS?

I have code snippent which is executed on click of a link which is as below cj_redirecturl="/HomeWork/main/load_course"; utility.xhttprw.data(cj_redirecturl,{data:courseid},function(response){ if(response){ …
OM The Eternity
  • 15,694
  • 44
  • 120
  • 182
7
votes
4 answers

JSP or JavaScript equivalent to PHP's $_SERVER["HTTP_HOST"]?

I've go an absolute URL in my JavaScript that I have hard coded for window.location. I don't want to have to change this every time I am testing my app. In PHP I would have handled this by testing the $_SERVER["HTTP_HOST"] variable to find out what…
cmcculloh
  • 47,596
  • 40
  • 105
  • 130
7
votes
5 answers

Window.location.hash help needed with syntax

My website is available at http://visualise.ca/ and when you load a post by clicking a thumbnail it will loads the post within the page using ajax. When you close the post it uses this code in order to change the url back to http://visualise.ca/…
Gab
  • 2,216
  • 4
  • 34
  • 61
7
votes
1 answer

Getting error Cannot destructure property 'protocol' of 'window.location' as it is undefined in nextjs application while building it

I am getting the error below in my nextjs application while building it. My nextjs application is configured with typescipt for building reasons though i am using js only. Build error occurred: TypeError: Cannot destructure property 'protocol' of…
Abdulmoiz Ahmer
  • 1,953
  • 17
  • 39
7
votes
1 answer

How to unit-test a function that calls window.location.href in Angular2

I have this function I need to test: login(): void { this.userService.setSessionAndDateOnlogin(); this.loginService.getLogin() .subscribe( octopusUrl => window.location.href = octopusUrl); } I use the window.location.href to…
stijn.aerts
  • 6,026
  • 5
  • 30
  • 46
7
votes
8 answers

Get root website url in javascript for redirect

I want to redirect to Login page from every page in my website after session timeout. I try to set window.location to the login page: var ParentUrl = encodeURIComponent(window.parent.location.href); document.location.href = "~/Login.appx?ReturnUrl="…
Inbal
  • 909
  • 2
  • 28
  • 46
6
votes
2 answers

Jquery: Getting certain url path using window.location

Our url pathname is www.nicadpower.com/index.com but we only want to get the pathname after www.nicadpower.com which is index.com how can we get index.com using window.location and jquery
DoYouWantaWebsite
  • 141
  • 1
  • 3
  • 13
6
votes
2 answers

Can't destroy AWS Cognito session from within React application

I'm trying to log out of my application that's using AWS Cognito by calling their logout endpoint. I'm not using the AWS SDK because as far as I can tell, it does not yet cover oauth app integrations and sign in using external federated identity…
6
votes
0 answers

window.location disconnecting websockets

I want to open a download link without opening a blank page (then, I won't be using window.open). Then I'm using window.location.href or window.location.assign. But the problem is that both methods disconnects my websockets connection. How can I…
João Paulo
  • 6,300
  • 4
  • 51
  • 80
6
votes
1 answer

electron's remote.getGlobal() returns "undefined" after window.location.replace()

I've been fiddling around with electron's remote module. In my main-process I've created this variable: global.storage = {}; My renderer-process is initialised with a file called startup.html. win.loadURL('file://' + __dirname +…
Himmelslaub
  • 105
  • 1
  • 8
6
votes
1 answer

Disable UI-Router Interaction with window.location

This is a long shot, but UI-router is so popular, thought maybe someone here would have insight on this issue. I'm migrating a project to Angular JS. The project consists of a page with several different panels - each of which is downloaded from the…
Eric H.
  • 6,894
  • 8
  • 43
  • 62