how to get host IP and port number on which the application is running using javascript

后端 未结 2 1340
暖寄归人
暖寄归人 2021-01-12 14:40

can anyone tell me how to get host IP and port number on which the web application is running using javascript (e.g. 127.0.0.1:8080)

2条回答
  •  星月不相逢
    2021-01-12 15:17

    document.location.host      // localhost:1234
    document.location.hostname  // localhost
    document.location.port      // 1234
    

提交回复
热议问题