js与jquery自动触发a链接的方法

admin4年前前端技术1107

自动触发a链接的方法如下:

1.

<body >
 <a  href="http://www.shengmake.net" ><span>Affiliate</span></a> 
</body>
<script src="jquery-3.6.0.min.js"></script>

<script type="text/javascript">
 $(document).ready(function() {
     setTimeout(function() {
  $("span").click();
    }, 1000);
  
 
 });
 
</script>



2.

<script type="text/javascript">
var lianjie="http://www.shengmake.net";
var aa = document.createElement("a");
aa.setAttribute("href", lianjie);
// aa.setAttribute("target", "_blank");
var bodys = document.getElementsByTagName("body")[0];
bodys.appendChild(aa);
aa.click();
</script>


关键知识点:不能设置target属性为_blank否则会被浏览器拦截


相关文章

Navigate down the menu through jquery development

The core knowledge is to use jquery's hover method to achieve, The animation effe...

让TD 与div自动换行的css方法

word-wrap: break-word;  word-break: break-all; white-space: normal;...

ios 手机端 input 框上方有内阴影

解决方案1:<!--如果 ui 样式里有边框,可以用外层盒子设置边框-->input{     border:none; }...

关于css的position参数自我领悟心得整理

relative :相对与最近的DOM定位   absolute :相对里面的绝对定位,跟relative 一起用,起到随心所欲定位的效果sticky :滚顶地位定位,用与鼠标滚动...

ubbedit实现遍历绝对目录绑定cookie查询以前上传的图片

ubbedit实现遍历绝对目录绑定cookie查询以前上传的图片

设置cookie ,$user_id=$_COOKIE["user_email"];设置path   , $path =  "/"...

jquery默认设置第一个类的css或者属性

var me=$("#cima>input");me.eq(0).css...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。