window.location

JQuery Mobile, redirecting by window.location prevents pageshow event

南楼画角 提交于 2019-12-06 09:50:50
问题 I have a JQuery Mobile application with many pages linked to each other. If I put a link on page A and set the href to page B, this script works fine: $(document).on('pageshow','#pageB',function(){ alert('hello!'); }); But if I put a button on page A and write this code for onclick event: window.location="pageB.html"; The pageshow event won't raise anymore! Where's the problem? How can I use window.location and still be able to catch the pageshow event? 回答1: When you use window.location or

Pass PHP Variable into Java Script window.location

淺唱寂寞╮ 提交于 2019-12-06 08:27:37
问题 I am trying to pass a php variable into a java script window.location that returns a user to the current list view after deleting an item from the database. I can't seem to get the syntax correct. Code: function confirmation(a) { var currString = "<? echo $currString ?>"; var answer = confirm("Are you sure you want to delete this item?") if (answer){ alert("The item has been deleted") window.location = "list.php?s='. $currString .'&=delete=true&id=" + a; } else{ alert("The item has not been

ngStorage not working properly when redirect using window.location

谁说我不能喝 提交于 2019-12-05 16:01:32
I'm trying to do a redirect after set a $storage var, using ngStorage module. This is not working, and I can't find out why. My code is below: <head> <script data-require="angular.js@1.1.5" data-semver="1.1.5" src="http://code.angularjs.org/1.1.5/angular.min.js"></script> <script src="https://rawgithub.com/gsklee/ngStorage/master/ngStorage.js"></script> <script> angular.module('app', [ 'ngStorage' ]). controller('Ctrl', function ( $scope, $localStorage ) { $scope.$storage = $localStorage.$default({ array: [] }); $scope.Redirect1 = function () { $scope.$storage.array = ['pineapple', 'pear',

Why won't window.location load a new page?

≯℡__Kan透↙ 提交于 2019-12-05 10:18:52
This bit of code used to work, and now it doesn't: var url = myurl +'?id=' + id + '&phase=' + phase; window.location = url; Using the IE dev toolbar I've verified that url has a valid url, and window.location returns the new url...the only problem is the page does not reload. Does anyone know of any reasons for window.location to now actually load a new document when it is assigned to? Use window.location.href = url; instead. Is your JavaScript running the onclick event from an <input> type=" button " or type=" submit "? If your button is type="submit" it won't work unless you stop the

Updating address bar window.location hash with scrollspy

馋奶兔 提交于 2019-12-04 19:08:59
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 respective anchor. That triggers a chain reaction in which the user will instantly end up at the top of

Pass PHP Variable into Java Script window.location

霸气de小男生 提交于 2019-12-04 12:09:55
I am trying to pass a php variable into a java script window.location that returns a user to the current list view after deleting an item from the database. I can't seem to get the syntax correct. Code: function confirmation(a) { var currString = "<? echo $currString ?>"; var answer = confirm("Are you sure you want to delete this item?") if (answer){ alert("The item has been deleted") window.location = "list.php?s='. $currString .'&=delete=true&id=" + a; } else{ alert("The item has not been deleted") } Try this: function confirmation(a) { var currString = "<?php echo $currString ?>"; var

window.top.location vs window.location

烈酒焚心 提交于 2019-12-04 08:08:17
how to sync window.top.location and window.location? This is how you set the parent of the frame ( top ) to the location of the frame document... top.location = self.location; Of course, this code must be executed within the iframe, and is succeptible to the Same-Origin Policy . Anant Dabhi window.top.location is return you to broswer's address bar location even you'r in i-frame or page.. window.location is return location of your current page address in case facebook apps. if you want to top query-string you have to use alert(window.top.location); if u want to replace top location then window

Refresh the parent window from the child window in javascript

落花浮王杯 提交于 2019-12-04 03:26:50
问题 I have looked for awhile and cannot find an answer that fits my needs. I have a page that pops a window (window.open), logs the user in (creates a cookie, set session) then redirects to another page. While the modal is redirecting, I would like to refresh the parent page, so all the good stuff that I just did will be recognized by the parent. I have tried window.opener and stuff like that. Can someone help me out a little? Thanks 回答1: window.opener in the popup will refer to the window object

possible to replace window.location.hash?

醉酒当歌 提交于 2019-12-03 14:27:57
问题 I'm wondering whether it's possible to change the hash in window.location.hash and replace it with 'this.id'. Or would I need to change the entire window.location? 回答1: Yes, you can. I do something similar at one of my sites, although with href instead of id , but id works too. A quick example: $('a[id]').click(function(e) { // This will change the URL fragment. The change is reflected // on your browser's address bar as well window.location.hash = this.id; e.preventDefault(); }); 来源: https:/

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

ⅰ亾dé卋堺 提交于 2019-12-02 20:36:13
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, Document.Write, or do any kind of output of window.top.location.href Concatenate it in any other variable,