How to make onclick automatically through onload function

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 14:24:41
$(document).ready(function() {
   $('#someLinkId').click();
});

Or

$(document).ready(function() {
   $('#someLinkId').trigger("click");
});
$(document).ready(function () {
   $("#myLink").trigger('click');
});

as you can read in: http://docs.jquery.com/Events/trigger#eventdata


$("#whateverid").trigger("click");

Where "whateverid" is the ID of the anchor tag, or whatever other selector you want to use.

What's the point of loading the page if you're going to navigate away from it immediately?

In addition to jQuery's triggering abilities, you could do:

<body onload="window.location.replace('http://example.com/');">

or:

<body onload="window.location.href = 'http://example.com/';">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!