Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

วิธีดึง Title และ Full URL ของเอกสารใน JavaScript

document.title ให้ tiêu đềเอกสาร document.URL ให้ URL เต็ม

Title ของเอกสาร

<html> <head> <title>Tutorix</title> </head> 
<body> <script> 
    document.write("The title of the document is " + document.title); 
</script> </body> </html>

ผลลัพธ์

Tutorix

URL ของเอกสาร

<html> <body> <script> 
    document.write("The URL of the document is: " + document.URL); 
</script> </body> </html>

ผลลัพธ์

The URL of the document is: https://www.tutorialspoint.com/cg/assets/ovPEzF.php