js关闭当前页面跳转新页面

时间:2022-03-28 10:42:56

页面代码:

  <p class="info"><span style="font-weight: bold">所属项目:</span>
@foreach($programList as $task)
@if($taskList->project == $task->id )
<span onclick="xiangmu({{$task->id}})" style="color: #3c8dbc;font-family: SimSun;cursor: pointer">{{$task->name}}</span>
@endif
@endforeach
</p>

其中,cursor: pointer,鼠标经过箭头变为小手

 <script>
function xiangmu(id)
{ window.open('{{url('taskDetail')}}'+'/'+id); //跳转
window.history.back(-1); //返回上一页面 }
</script>

效果:js关闭当前页面跳转新页面