Problems with intranet and extranet hyperconnection_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:15:27
Original
1174 people have browsed it

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


Reply to discussion (solution)

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>
Copy after login

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>
Copy after login

Yes, the test was successful. Wait two days for the test to be completed and see if it can be completed by html code

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template