location-href

Jest error when set or assign window.location

扶醉桌前 提交于 2021-02-18 12:38:08
问题 Upgraded Jest library on v25 and all unit tests that were checking location change are failing. I checked a couple of issues opened on jest repo but I didn't actually understood how can this be fixed. The code that calls location.assign breaks with following error: Error: Not implemented: navigation (except hash changes) 69 | // window.location.href = url; > 70 | window.location.assign(url); I suppose that Jest jsdom window object shouldn't be treated anymore like a real browser window in

Reload a page with location.href or window.location.reload(true)

走远了吗. 提交于 2020-07-17 06:28:29
问题 I need to reload a page in a success of an ajax call. I'm seeing some code (not mine) and there are two ways: success : function(obj) { //code location.href = location.href; } or success : function(obj) { //code window.location.reload(true); } Is there any difference in the behaviour? I know the difference of both location and window.location but in terms of do the job? 回答1: The main difference is follow: window.location.reload() reloads the current page with POST data, while window.location

Reload a page with location.href or window.location.reload(true)

风流意气都作罢 提交于 2020-07-17 06:28:25
问题 I need to reload a page in a success of an ajax call. I'm seeing some code (not mine) and there are two ways: success : function(obj) { //code location.href = location.href; } or success : function(obj) { //code window.location.reload(true); } Is there any difference in the behaviour? I know the difference of both location and window.location but in terms of do the job? 回答1: The main difference is follow: window.location.reload() reloads the current page with POST data, while window.location

How can I get window.location.href in Elm?

为君一笑 提交于 2020-04-13 03:59:32
问题 I have an index.html which contains my Elm app. The Elm app uses various GET s to an API served by the same server as the one that serves the index.html . Rather than hardcode the URLs in my Elm code for the GET s, e.g.: url = "http://localhost:8080/api/tasks" is there a function which returns the value of window.location.href ? I'd like to do something like: url = getHref() ++ "/api/tasks" In this way, if I move my server to somewhere else I will not need to update all the urls in my Elm

How to remove trailing slash from window.location.pathname

帅比萌擦擦* 提交于 2020-02-02 03:57:07
问题 I have the following code that's allowing me to switch between desktop and mobile versions of my website, <script type="text/javascript"> if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { window.location = "http://m.mysite.co.uk"; } </script> I recently realised all that does is send everyone to the homepage of the site. I dug around a bit and figured I could redirect specific pages to the mobile version by amending the above to, <script type=

Selecting the anchor tag of a particular href using jQuery

蓝咒 提交于 2020-01-13 05:58:07
问题 THE AIM After refreshing the browser, I would like that the user stays in the menu/content they were before refreshing. THE PROBLEM After refreshing the browser, the content of the particular menu in which the user was before refreshing is shown as active (i.e. it is shown on the screen). However, the menu icon of that particular content is NOT shown as active (i.e. it does not show a black colour). I am struggling in selecting the anchor element (where the icon is found) of the current href

Button onClick event and Href-Location

試著忘記壹切 提交于 2019-12-25 08:13:43
问题 I used a solution given by "Chrules" found in this discussion:buttons with no href, onclick etc like this : <button id="clickable" >Click Me!!</button> ...... $("#clickable").click(function(){ // Send user to this link insertRecord(); //SQLite Code location.href = "game.html"; // location.href = "http://www.takemehere.com"; }); So When i used the location.href like he putted it (= "http://www.takemehere.com";) The insertRecord() method is done with success (the object is added to the database

Possible to get query parameters of the <script> src JavaScript URL?

家住魔仙堡 提交于 2019-12-24 06:39:04
问题 As an example, I have the following html: <body> <script src="code.js?q=xyz"></script> </body> I want to be able to read the q=xyz query parameter from within code.js . I tried: console.log(window.location.href) But it gives me the html document's URL, not code.js 's URL (I could then parse the URL for the query parameters). Is there any way to get an imported JavaScript file's query parameters from within that JavaScript? I know I could read the query parameters on a server and then send

FancyBox close from within iframe and take parent page to the link

左心房为你撑大大i 提交于 2019-12-18 12:09:52
问题 I found applying the following function to a links onclose works to close Fancybox from within an iFrame: parent.$.fancybox.close(); I want to take this further and have the link take the parent page to a new url. I've tried the following but it doesn't work: <a onclick="location.href='http://www.domain.com/page/';parent.$.fancybox.close();"> Close and go to page</a> using a href doesn't work either as the onclose takes precedence. 回答1: Very simple solution... can't believe I didn't think of

href link to # question

早过忘川 提交于 2019-12-13 06:43:40
问题 I have a question about the href link, tried googling it but could not find much info on this. I have a href link like this: <a href='#' onclick='openSerialWindow();return false;'><h:outputText value="#{i18n.regFindSerialNumber}" /></a> previously the # was replaced by the page.htm that it should link to and that caused an error when user right clicked on the link and chose 'Open in new window/tab'. After replacing the page.htm with # it works fine user can even r/c and open it in new tab