iis服务器助手广告广告
返回顶部
首页 > 资讯 > 前端开发 > JavaScript >解决JS请求路径控制台报错 Failed to launch'xxx' because the scheme does not have a registered handler的
  • 902
分享到

解决JS请求路径控制台报错 Failed to launch'xxx' because the scheme does not have a registered handler的

js请求路径控制台报错js控制台报错 Failed to launch 2023-03-08 17:03:29 902人浏览 独家记忆
摘要

目录控制台报错: Failed to launch ‘xxx’ because the scheme does not have a reGIStered h

控制台报错: Failed to launch ‘xxx’ because the scheme does not have a registered handler.

这种错误是因为请求没有协议,应该把协议头加上

错误的例子

     window.location.href="localhost:8080/GoShowJSP"

正确的例子

     window.location.href="Http://localhost:8080/goShowJSP"

扩展:js获取请求路径中参数值

获取请求路径中的参数值

function getQueryString() {  
  var qs = location.search.substr(1), // 获取url中"?"符后的字串  
    args = {}, // 保存参数数据的对象
    items = qs.length ? qs.split("&") : [], // 取得每一个参数项,
    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 参数值的方法如下:

我的需求是根据请求参数控制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")
        }
    })

到此这篇关于解决JS请求路径控制台报错 Failed to launch'xxx' because the scheme does not have a registered handler的问题的文章就介绍到这了,更多相关js请求路径控制台报错内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: 解决JS请求路径控制台报错 Failed to launch'xxx' because the scheme does not have a registered handler的

本文链接: https://www.lsjlt.com/news/199037.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作