การใช้แท็ก base ในภาษา HTML

| ไอที | HTML | 7211

การใช้แท็ก base ในภาษา HTML

แท็ก <base> ใช้สำหรับการกำหนด url พื้นฐาน หรือ url ที่มีความสัมพันธ์กัน

ตัวอย่างเช่น
เราใส่แท็ก <base href="http://www.doesystem.com/" target="_blank"> เป็นแบบนี้
จากนั้นเราก็ใส่ลิ้งค์ให้ไปที่หน้า <a href="index.php">index</a> เมื่อเราคลิกที่ลิ้งค์ ลิ้งค์จะพาเราไปยังหน้า http://www.doesystem.com/index.php และเปิดหน้าใหม่ให้เรา

เราสามารถใส่แท็ก base ได้สูงสุดเพียง 1 แท็ก ในหน้าเอกสารหน้าหนึ่งเท่านั้น และจะต้องอยู่ภายในแท็ก head ด้วย

Browser Support

- Internet Explorer
- Firefox
- Chrome
- Safari
- Opera
บราวเซอร์ที่สำคัญ ๆ รองรับการทำงานของแท็ก base ทั้งหมด

Attributes ในแท็ก base

AttributeValueDescription
hrefURLSpecifies the URL of a page or the name of the anchor that the link goes to.
target_blank
_parent
_self
_top

Where to open the target URL.

  • _blank - the target URL will open in a new window
  • _self - the target URL will open in the same frame as it was clicked
  • _parent - the target URL will open in the parent frameset
  • _top - the target URL will open in the full body of the window

ตัวอย่างการใช้งาน

<head>
	<base href="http://www.doesystem.com" />
</head>
<img src="/images/base.gif" />
comments




เว็บเพื่อนบ้าน
DoesystemDevcodeMathMySelfHowToClicksBlogJavaExample