Tech Programing


Multiple IP addresses of a website, open one that works

1 min read

Working on a search bar that links to the client’s catalogue (located at a different URL). The catalogue website has two different IP addresses: local and external. If using on-premise Wi-Fi, the local IP address works but the external doesn’t. I need to open whichever IP address is working for a client. It’s a WordPress website where I have zero access to anything except their frontend so I’m pretty much stuck with JS.

As of now, I’m opening both links when someone clicks.

window.open(`IP_External?idx=ti&q=${document.getElementById('searchText').value}`, `_blank`);

window.open(`${document.getElementById('searchText').value}`, `_blank`);   

I want to check the external IP address. If it works or responds on time (say 5 seconds), I use that IP address otherwise the local one. How do I do this?

(Sorry, pretty noob in web dev)

Source link



發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *