Base targetProperty

Base 对象参考手册Base Object

Definition and Usage

The target property can set or return the value of the target attribute in the base element.

The target attribute specifies where to open all links in the page.

Syntax

baseObject.target=value

The target attribute can be one of the following values:

Value Description
_blank Open the link in a new window
_self Open the link in the same frame (default).
_parent Open the link in the parent frame
_top Open the link in the window document.
framename Open the link in a specified frame


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the target attribute.


Example

Example

Return the target attribute of the base link for all links in the page:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<base id="htmldom" target="_blank" href="../jsref/index.html">
</head>
<body>

<p>The base URL for all links:
<script>
document.write(document.getElementById("htmldom").target);
</script>
</p>

</body>
</html>

The output of the above example:

The base link for all links: _blank

Try it Yourself »


Base 对象参考手册Base Object Other Extensions