click()
creates an on-click event and attaches it to the object. It doesn't actually cause a click, it just creates a function that executes after a user's click if/when they choose to do so.
What you're looking for is trigger()
, which lets you simulate a click without the user actually initiating it. Also, you should the ready
event instead of the load
event in most cases.
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(window).ready(function() {
$('a').trigger('click');
});
</script>
</head>
<body>
<a href="http://www.google.com" target="_blank">Report</a>
</body>
</html>
Another thing to note - what you're trying to do may be blocked by popup blockers, as they're designed to stop a website from opening a new window when the page is loaded.