解決JS請(qǐng)求路徑控制臺(tái)報(bào)錯(cuò)?Failed?to?launch'xxx'?because?the?scheme?does?not?have?a?registered?handler的問(wèn)題
控制臺(tái)報(bào)錯(cuò): Failed to launch ‘xxx’ because the scheme does not have a registered handler.
這種錯(cuò)誤是因?yàn)檎?qǐng)求沒(méi)有協(xié)議,應(yīng)該把協(xié)議頭加上
錯(cuò)誤的例子
window.location.href="localhost:8080/goShowJSP"
正確的例子
window.location.href="http://localhost:8080/goShowJSP"
擴(kuò)展:js獲取請(qǐng)求路徑中參數(shù)值
獲取請(qǐng)求路徑中的參數(shù)值
function getQueryString() { var qs = location.search.substr(1), // 獲取url中"?"符后的字串 args = {}, // 保存參數(shù)數(shù)據(jù)的對(duì)象 items = qs.length ? qs.split("&") : [], // 取得每一個(gè)參數(shù)項(xiàng), item = null, len = items.length; for(var i = 0; i < len; i++) { item = items[i].split("="); var name = decodeURIComponent(item[0]), value = decodeURIComponent(item[1]); if(name) { args[name] = value; } } return args; }
對(duì)于 http://localhost/index.html?q1=abc&q2=efg&q3=h 的url,獲取 q1 參數(shù)值的方法如下:
我的需求是根據(jù)請(qǐng)求參數(shù)控制tab切換
$(document).ready(function(){ $("#1").click(function(){ $(".bidinfo-tab li").removeClass("current"); window.location.href="/m/front/invest/investList" }) $("#2").click(function(){ $(".bidinfo-tab li").removeClass("current"); window.location.href="/m/front/invest/investList?type=1" }) $("#3").click(function(){ $(".bidinfo-tab li").removeClass("current"); window.location.href="/m/front/invest/investList?type=2" }) var type=location.search.substr(1).split("=")[1]; if(type=="1"){ $("#2").addClass("current") }else if(type=="2"){ $("#3").addClass("current") }else{ $("#1").addClass("current") } })
到此這篇關(guān)于解決JS請(qǐng)求路徑控制臺(tái)報(bào)錯(cuò) Failed to launch'xxx' because the scheme does not have a registered handler的問(wèn)題的文章就介紹到這了,更多相關(guān)js請(qǐng)求路徑控制臺(tái)報(bào)錯(cuò)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
微信小程序手動(dòng)添加收貨地址省市區(qū)聯(lián)動(dòng)
這篇文章主要為大家詳細(xì)介紹了微信小程序手動(dòng)添加收貨地址省市區(qū)聯(lián)動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-05-05如何通過(guò)vscode運(yùn)行調(diào)試javascript代碼
這篇文章主要介紹了如何通過(guò)vscode運(yùn)行調(diào)試javascript代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-07-07Object的相關(guān)方法 和 js遍歷對(duì)象的常用方法總結(jié)
這篇文章主要介紹了Object的相關(guān)方法 和 js遍歷對(duì)象的常用方法,結(jié)合實(shí)例形式總結(jié)分析了Object對(duì)象操作的操作方法與js遍歷的三種常用方法,需要的朋友可以參考下2023-05-05typescript基本數(shù)據(jù)類(lèi)型HTMLElement與Element區(qū)別
這篇文章主要為大家介紹了typescript基本數(shù)據(jù)類(lèi)型HTMLElement與Element區(qū)別詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11微信小程序?qū)崿F(xiàn)canvas分享朋友圈海報(bào)
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)canvas分享朋友圈海報(bào),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-06-06整理關(guān)于Bootstrap過(guò)渡動(dòng)畫(huà)的慕課筆記
這篇文章主要為大家整理了關(guān)于Bootstrap動(dòng)畫(huà)過(guò)渡的慕課筆記,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-03-03