解決JS請求路徑控制臺報錯?Failed?to?launch'xxx'?because?the?scheme?does?not?have?a?registered?handler的問題
控制臺報錯: Failed to launch ‘xxx’ because the scheme does not have a registered handler.
這種錯誤是因為請求沒有協(xié)議,應(yīng)該把協(xié)議頭加上
錯誤的例子
window.location.href="localhost:8080/goShowJSP"
正確的例子
window.location.href="http://localhost:8080/goShowJSP"
擴展:js獲取請求路徑中參數(shù)值
獲取請求路徑中的參數(shù)值
function getQueryString() { var qs = location.search.substr(1), // 獲取url中"?"符后的字串 args = {}, // 保存參數(shù)數(shù)據(jù)的對象 items = qs.length ? qs.split("&") : [], // 取得每一個參數(shù)項, 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; }
對于 http://localhost/index.html?q1=abc&q2=efg&q3=h 的url,獲取 q1 參數(shù)值的方法如下:
我的需求是根據(jù)請求參數(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請求路徑控制臺報錯 Failed to launch'xxx' because the scheme does not have a registered handler的問題的文章就介紹到這了,更多相關(guān)js請求路徑控制臺報錯內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
如何通過vscode運行調(diào)試javascript代碼
這篇文章主要介紹了如何通過vscode運行調(diào)試javascript代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-07-07Object的相關(guān)方法 和 js遍歷對象的常用方法總結(jié)
這篇文章主要介紹了Object的相關(guān)方法 和 js遍歷對象的常用方法,結(jié)合實例形式總結(jié)分析了Object對象操作的操作方法與js遍歷的三種常用方法,需要的朋友可以參考下2023-05-05typescript基本數(shù)據(jù)類型HTMLElement與Element區(qū)別
這篇文章主要為大家介紹了typescript基本數(shù)據(jù)類型HTMLElement與Element區(qū)別詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-11-11微信小程序?qū)崿F(xiàn)canvas分享朋友圈海報
這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)canvas分享朋友圈海報,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-06-06