Reputation: 1277
I am trying to open a network folder by using the following in my extjs javascript project.
window.open("http://127.0.0.1:8887/a/b/");
the above works fine but when there is a space in the path it no longer works
window.open("http://127.0.0.1:8887/a/b c/");
the above does not work. anyone see what I am doing wrong?
Upvotes: 0
Views: 128
Reputation: 4768
document.addEventListener("DOMContentLoaded", doStuff);
function doStuff(){
let button = document.getElementById("navButton");
console.log(button);
button.onclick = () => {
var url="http://localhost:3000/a/ c/index.html";
url = encodeURI(url);
console.log(url);
window.open(url, "_new");
};
}
<button id="navButton">Click Me</button>
I think you need to encode the URL first.
let url = "http://127.0.0.1/a/d/ c/";
let encoded = encodeURI(url);
console.log(encoded);
//window.open(encoded);
Upvotes: 1