My website access address: LAN: 10.0.0.8 External network access address: www.xxx.com
Set the ABCDE hyperlink in the web page to
If in the LAN: Equivalent to: ABCDE
If in the external network: Equivalent to:ABCDE
The problem is that there is a special connection
in the LAN: 10.0.0.8 :81/b.html
On the external network : www.xxx.com:81/a.html How do I write code
If there is a port, it must be written as an absolute path
Write relative paths. When the link is opened, the browser will automatically add the corresponding server path
For example,
< ;a href="a.html">A
I use http://www.xxx.com:81 to access the external network. When I click the link, it will automatically open www.xxx.com:81 /a.html
Use IP to access the intranet. When you click the link, it will automatically open http://10.0.0.8:81/a.html
If it is cross-domain, the above will not work. ( Different addresses or different ports are usually cross-domain)
As 2# said, just bring the port number when accessing.
If it is a special requirement, the port number is not included when accessing, but a special page requires a port number. You can use js to obtain the host header and output the link
<script>var host=location.host;//主机头var inet=host.indexOf('xxx.com')//外网document.write('<a href="http://'+host+':81/'+(inet?'a':'b')+'.html">ABCDEFG</a>');</script>
Change
<script>var host=location.host;//主机头var inet=host.toLowerCase().indexOf('xxx.com')!=-1//外网////////document.write('<a href="http://'+host+':81/'+(inet?'a':'b')+'.html">ABCDEFG</a>');</script>
Yes, the test was successful. Wait two days for the test to be completed and see if it can be completed by html code