Home > Article > Web Front-end > How to use domain attribute
The domain attribute can return the domain name of the server for downloading the current document. Let's take a look at the specific methods of the domain attribute.
#The domain attribute is a read-only string that contains the host name of the web server that is loading the current document.
Let’s first take a look at the basic syntax of the domain attribute
document.domain
Note: The domain attribute can solve the attribute sharing problem of different documents caused by the same-origin security policy.
Let’s look at the specific examples
The code is as follows
<!DOCTYPE html> <html> <body> 本文档的域名是: <script type="text/javascript"> document.write(document.domain) </script> </body> </html>
This article ends here. For more exciting content, you can pay attention to other posts on the php Chinese website Related column tutorials! ! !
The above is the detailed content of How to use domain attribute. For more information, please follow other related articles on the PHP Chinese website!