Sunday, August 29, 2010

jQuery target attribute instead of javascript window.open

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery target attribute instead javascript window.open</title>


<script src="jquery-1.4.2.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function () {
$("a.new-window").append(' <em>(new window)</em>').attr('target', '_blank');
});


</script>

</head>

<body>

<a class="new-window" href="http://www.google.co.in">Google in new window</a>
<br />
<a href="http://www.in.msn.com">MSN in same window</a>

</body>
</html>

For better explanation visit to - http://www.456bereastreet.com/archive/201006/new_windows_with_javascript_and_the_target_attribute/

No comments:

Post a Comment