window.location

window.location versus just location

 ̄綄美尐妖づ 提交于 2019-11-27 12:16:19
Across the web, I see a vast number of JavaScript programmers writing window.location instead of just location . I was curious if anyone could offer an explanation as to why. window is the global object, and therefore it is unnecessary to include -- isn't it? I mean, you don't see people write window.Math.floor or new window.Date() , so I'm curious as to why it would be specified with location . I understand that location is considered to be a "property" of the window you're in, which I suppose makes some sense. But even so, I don't see any reason to specify the global object; it's not

Clearing URL hash

感情迁移 提交于 2019-11-27 11:43:56
问题 Visit stackoverflow.com/#_=_ and window.location.hash evaluates to #_=_ . Fine. Now execute window.location.hash = '' to clear the hash, and the URL becomes stackoverflow.com/# . (Notice the trailing # .) Why is the # in window.location.hash inconsistently included or excluded? How can the # be removed from the URL without reloading the page? (MDN says [the hash is] the part of the URL that follows the # symbol, including the # symbol. but that is not true for in the case of an empty hash.)

Adding http headers to window.location.href in Angular app

倾然丶 夕夏残阳落幕 提交于 2019-11-27 08:36:45
I have a angular app that I needed to redirect outside to a non angular html page, so I thought I could just use the $window.location.href to redirect the angular app to my external site. This actually works fine, however, I have a nodejs/express backend that checks for auth token before serving up any content(even static content). This requires a auth token to be sent in the header of the http request. Now the question: Can/How do you add an auth token to the request that is made by changing the $window.location.href before it is sent off? When you use $window.location.href the browser is

window.location = #anchor doesn't work in IE

馋奶兔 提交于 2019-11-27 03:40:06
问题 On this map: http://web.pacific.edu/documents/marketing/campus-map/version%202/stockton-campus-2.0.htm I have an anchor at the top, and I want the page to jump to the anchor when a link is clicked. I'm currently using window.location = '#top'; It works as expected in FF, Opera, and Chrome, but not in IE 7. I've tried all permutations like window.location.hash and window.location.assign() and also scrollIntoView(true) and focus(). How can I make it work in IE? Edit : Nothing seems to work,

Difference between window.location.assign() and window.location.replace()

余生颓废 提交于 2019-11-27 03:14:51
What is the difference between window.location.assign() and window.location.replace() , when both redirect to a new page? RedAnthrax Using window.location.assign("url") will just cause a new document to load. Using window.location.replace("url") will replace the current document and replace the current History with that URL making it so you can't go back to the previous document loaded. Reference: http://www.exforsys.com/tutorials/javascript/javascript-location-object.html Matt Ball According to MDN: The difference from the assign() method is that after using replace() the current page will

Is it secure to use window.location.href directly without validation

这一生的挚爱 提交于 2019-11-27 02:41:32
问题 Is it secure to use window.location.href without any validation? For example: <script> var value = window.location.href; alert(value); </script> From the above example, is it vulnerable to Cross-site scripting (XSS) attack? If it is, then how? How the attacker can modify the value of window.location.href to the malicious content? Edit (Second Situation) This is the url : www.example.com?url=www.attack.com Just assume taht I have a getQueryString() function that will return value without

window.location.href not working

*爱你&永不变心* 提交于 2019-11-26 23:14:27
问题 My website is http://www.collegeanswerz.com/. I'm using rails. The code is for searching for colleges. I want the user to be able to type in the colleges name, click enter, and be taken to the url, rather than seeing the search results (if the user types in the name properly. if not I want to show the search results). I'm using "a" and "stackoverflow.com" as placeholders while I try to get it to work. I'm using window.location.href based on this: How to redirect to another webpage in

Triggering shouldStartLoadWithRequest with multiple window.location.href calls

陌路散爱 提交于 2019-11-26 22:47:55
问题 Im trying to pass multiple things from a webpage inside a UIWebView back to my iPhone app via the shouldStartLoadWithRequest method of the UIWebView. Basically my webpage calls window.location.href = "command://foo=bar" and i am able to intercept that in my app no problem. Now if i create a loop and do multiple window.location.href calls at once, then shouldStartLoadWithRequest only appears to get called on once and the call it gets is the very last firing of window.location.href at the end

Setting JavaScript window.location

南笙酒味 提交于 2019-11-26 22:41:12
问题 I'm currently setting the window.location.pathname property to redirect the user to a relative URL. The new URL has parameters, so the line of JavaScript looks like this: window.location.pathname = window.location.pathname.substring( 0, window.location.pathname.lastIndexOf( '/' ) + 1 ) + 'myPage.xhtml?u=' + selected_user.Username; This is successful in Firefox, however Chrome encodes the question mark with '%3F' and the request subsequently fails. I'm not sure if I'm using window.location

window.location versus just location

我是研究僧i 提交于 2019-11-26 22:21:57
问题 Across the web, I see a vast number of JavaScript programmers writing window.location instead of just location . I was curious if anyone could offer an explanation as to why. window is the global object, and therefore it is unnecessary to include -- isn't it? I mean, you don't see people write window.Math.floor or new window.Date() , so I'm curious as to why it would be specified with location . I understand that location is considered to be a "property" of the window you're in, which I