I have a web application which is deployed at some port say 8085, and hostname is sample.something.com. Using window.location.host or window.location.port, the port is coming as blank. How can i retrieve the port number using javascript , can anyone help me out?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
If
window.location.port
is empty that means the application is running on port 80 for http and 443 for https.As mentioned in a comment, you can use
window.location.protocol
to check what protocol is used (http or https).Implementation: