window.location

window.location call popup up empty dialog on safari

南楼画角 提交于 2019-12-25 04:51:59
问题 on a web page i am trying to redirect the browser to another page on the same site. the code is very simple for that: window.location = "/path1/path2" on safari - both windows as well as mac - a message box containing only the text "http://domain.com" comes up. I have tried different ways of specifying this: location.href, windows.assign(...) ... and the all have the same behavior. Did any of you see this? and do you have a solution for this? Thanks. 回答1: take a look at this question. You

jQuery window.location.replace keeps looping

本秂侑毒 提交于 2019-12-25 02:19:01
问题 I'm using window.location.replace() with jQuery to redirect to a new page in wordpres if you got a older browser in either Internet explorer or Firefox due to my html5 layout. var browser = jQuery.browser; var version = browser.version.slice(0.3); if ( browser.msie && version != "10.0" && version != '9.0' ) { window.location.replace("http://crosscom.dk/update-browser"); } if ( browser.mozilla && version != "17.0" && version != '16.0' && version != '15.0' ) { window.location.replace("http:/

How to get anything following the domain in a url, using Javascript

六眼飞鱼酱① 提交于 2019-12-24 08:37:57
问题 What is the best way to get the "anything" part after the domain part, using Javascript: http://www.domain.com/anything http://www.domain.com/#anything http://www.domain.com/any/thing For http://www.domain.com/#anything I would have to use window.location.hash . But for http://www.domain.com/anything I would have to use window.location.pathname . I'm using: window.location.href.replace(window.location.origin, "").slice(1) Are there any caveats with this solution? Is there a better way? 回答1:

Change window.location prototype to disable certain redirects?

别说谁变了你拦得住时间么 提交于 2019-12-23 08:51:37
问题 I'm trying to selectively disable window.location , using Greasemonkey, at the start of the document. I don't want to fully disable javascript, just disable some redirects done with javascript. They look like this: window.location = "unwanted url"; 回答1: You can't change the window.location prototype, because this a "native property" of window and it is not configurable. On Firefox (Greasemonkey), if you try to override this then you will get errors like: TypeError: can't redefine non

$window.location.href NOT WORKING in AngularJS

强颜欢笑 提交于 2019-12-23 07:58:26
问题 I'm building a basic AngularJS Login page and the $window.location.href did not re-direct the page to a new html in my system, hosted by WAMP. I even tried re-directing it to google. Nothing happens. I tried all the available solutions here and nothing seems to work. Any solutions ? JS followed by HTML var app = angular.module('myApp', []); app.controller('MainCtrl', function($scope) { $scope.name = 'World'; $scope.submit = function() { if ($scope.username && $scope.password) { var user =

Mock window.location.reload in Jasmine testing

心已入冬 提交于 2019-12-22 02:00:54
问题 I have created a window.location.reload function in my javascript. I need to mock the reload function while testing in Jasmine since it keeps on looping. The test goes well when I run grunt jenkins . But not while testing in the browser (mozilla/chrome). Here is my code snippet. Javascript: window.location.reload(); Jasmine Test: spyOn(window.location, 'reload').and.callFake(function(){}); Can anyone please help me on this? 回答1: Thanks for sharing your views. I did a work around as suggested

Mock window.location.reload in Jasmine testing

落花浮王杯 提交于 2019-12-22 01:54:26
问题 I have created a window.location.reload function in my javascript. I need to mock the reload function while testing in Jasmine since it keeps on looping. The test goes well when I run grunt jenkins . But not while testing in the browser (mozilla/chrome). Here is my code snippet. Javascript: window.location.reload(); Jasmine Test: spyOn(window.location, 'reload').and.callFake(function(){}); Can anyone please help me on this? 回答1: Thanks for sharing your views. I did a work around as suggested

Updating address bar window.location hash with scrollspy

荒凉一梦 提交于 2019-12-21 21:46:35
问题 I've got a menu with scrollspy (using twitter boostrap). I want update the window.location.hash when the user scrolls down to a next section. The following code works when the user scrolls down: $(window).on('activate.bs.scrollspy', function (e) { location.hash = $("a[href^='#']", e.target).attr("href") || location.hash; }); However it does not work very well when the user scrolls upwards. The reason for this is that setting a new location.hash triggers the browser to navigate towards that

Use of window.location doesn't work on iPad

柔情痞子 提交于 2019-12-21 07:34:34
问题 I'm using some JavaScript that will redirect the user to another URL after a fixed period of time. This is working well on all browsers but on an iPad 3 I have to test on it isn't working. The timeout fires and I call window.location = "www.someurl.com"; and I've also tried window.location.href = "www.someurl.com"; I can see the URL in the browser changing to www.someurl.ocom but the browser doesn't actually go there - it stays on the same page. Is there something iPad specific I have to do

What exactly can an IFrame do with the top.Location object (cross-domain)?

左心房为你撑大大i 提交于 2019-12-20 09:53:53
问题 There is a very particular edge case in cross-domain policies regarding the window.top.Location object... Let's say I have IFrame A , in domain www.bbb.com, living inside a page in domain www.aaa.com. The page inside the IFrame can: Compare window.top.location to window.location (to detect whether it's being framed) Call window.top.location.replace(window.location) to redirect to self Call window.top.location.replace("any arbitrary string") to redirect somewhere else But it cannot: Alert,