简体   繁体   English

java 脚本重定向到另一个 url 不起作用,它附加了 url

[英]java Script redirect to another url doesn't work, it appends the url

I want to scan an QR Code with an url, and when it scans it should redirect to the url page from the QR Code, but it only appends it to my current URL, so it redirects to an false URL I want to scan an QR Code with an url, and when it scans it should redirect to the url page from the QR Code, but it only appends it to my current URL, so it redirects to an false URL

var scanner = new Instascan.Scanner({ video: document.getElementById('preview'), scanPeriod: 5, mirror: false });
        scanner.addListener('scan',function(content){
            //alert(content);
            console.log("Das ist der Content: " + content);
            //window.location.href='content';
            window.location = content;
        });

it should redirect to ' http://digital-selforder.com/suche.php?zid=1ABCDE ' but it could be any url or something like google.com it should redirect to ' http://digital-selforder.com/suche.php?zid=1ABCDE ' but it could be any url or something like google.com

i just needed to add http:// to my url, otherwise it couldn't redirect, so now it takes me to the right website我只需要将 http:// 添加到我的 url 中,否则它无法重定向,所以现在它带我到正确的网站

var scanner = new Instascan.Scanner({video: document.getElementById('preview'), scanPeriod: 5, mirror: false});
        scanner.addListener('scan', function (content) {
            //alert(content);
            console.log("Das ist der Content: " + content);
            window.location.replace("http://" + content);

        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM