0

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?

1 Answer 1

1

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);

Sign up to request clarification or add additional context in comments.

2 Comments

I tried and not working. I think it is because I don't understand the path. this works window.open("127.0.0.1:8887/a/b/"); but the above does not work. here is the weird part... the output is writing to the console... if I click on that path in the console output, it opens successfully. BUT when the my code hits window.open(encoded), nothing happens at all. any ideas?
Ok, I set up a sample project in VSCode on a Mac, using Lite-Server loading into Chrome. See the code below, it worked just fine. Opening the page into a new window.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.