Sie sind auf Seite 1von 4

<!

DOCTYPE html>
<html>
<body>
<p><a id="myAnchor" href="http://www.example.com:80/test.htm#part2">Example link
</a></p>
<p>Click the button to display the pathname of the link above.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myAnchor").pathname;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p><a id="myAnchor" href="http://www.example.com:4097/test.htm#part2">Example li
nk</a></p>
<p>Click the button to display the port number of the link above.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myAnchor").port;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p><a id="myAnchor" rel="nofollow" href="http://www.w3schools.com/">W3Schools</a
></p>
<p>Click the button to display the value of the rel attribute of the link above.
</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {

var x = document.getElementById("myAnchor").rel;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p><a id="myAnchor" href="http://www.example.com:80/test.htm?id=searchtest">Exam
ple link</a></p>
<p>Click the button to display the querystring part of the link above.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myAnchor").search;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p><a id="myAnchor" href="http://www.w3schools.com">W3Schools</a></p>
<p>Click the button to set the value of the target attribute of the link above t
o "_blank".</p>
<p><b>Note:</b> Try the link before and after you have clicked the button!</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("myAnchor").target = "_blank";
document.getElementById("demo").innerHTML = "The value of the target attribu
te was set.";
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p><a id="myAnchor" href="http://www.example.com/test.htm#part2">Example link</a
></p>

<p>Click the button to display the text content of the link above.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myAnchor").text;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p><a id="myAnchor" type="text/html" href="http://www.w3schools.com/">W3Schools<
/a></p>
<p>Click the button to display the value of the type attribute of the link above
.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myAnchor").type;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p><a id="myAnchor" href="https://johnsmith:smith123@www.example.com">Example li
nk</a></p>
<p>Click the button to display the username part of the link above.</p>
<button onclick="myFunction()">Try it</button>
<p><b>Note:</b> The username property is not supported in Internet Explorer, Saf
ari and Opera version 12 (and earlier).</p>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myAnchor").username;
document.getElementById("demo").innerHTML = x;
}

</script>
</body>
</html>

Das könnte Ihnen auch gefallen