各种页面跳转或当前页跳转的方法

onclick="javascript:window.open('operationLog.jsp','_blank');" //新窗口打开页面  _blank就是新窗口
onclick="javascript:window.open('http://www.baidu.com','_self');" //可以需要刷新当前页面或者覆盖当前页面  -self就是当前页面
onclick="javascript:location.href='Logout.do'"  //当前窗口打开页面


onclick='javascript:$("#main").load("Model2.do");'    //当前页面id为main的模块加载新页面 ,如果多个链接都是当前模块刷新建议写成一个方法,再进行调用
load里面如果传入的是action或mvc的接口也会自动执行完并加载返回的页面,因此传入的接口必须返回的是页面

如果不想使用load,就想自己执行ajax然后接口返回的是页面,把这个页面刷新到模块中,那也可以使用以下:
$("#main").html(ajaxResponse);  //只不过是load更智能帮我们执行完接口再把结果加载了


window.xxx.innerHTML=document.getElementById('xx').innerHTML;   //如果没用jquery ,那就使用原始的加载id为xx的所有html内容到到name为xxx的div中
window.parent.xxx.innerHTML=document.getElementById('xx').innerHTML;  //如果没用jquery ,那就使用原始的加载id为xx的所有html内容到父窗口的name为xxx的div中


<form name="form1" method="post" action="Model2.do" target='_blank'>  //form表单也可以设置target='_blank'从而达到提交后跳转到提交接口返回的那个页面


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
uniapp提供了几种页面跳转方法,包括uni.navigateTo、uni.redirectTo、uni.reLaunch、uni.switchTab和uni.navigateBack。其中,uni.navigateTo用于保留当前页面,跳转到应用内的某个页面,可以使用uni.navigateBack返回到原页面。可以通过传递参数字符串或对象来传递参数。\[2\]uni.redirectTo用于关闭当前页面并跳转到其他非tabbar页面,也可以带参数。\[2\]uni.reLaunch用于关闭所有页面,打开到应用内的某个页面,也可以带参数。\[2\]uni.switchTab用于跳转到tabbar页面,并关闭其他非tabbar页面,不可传递参数。\[2\]uni.navigateBack用于关闭当前页面,返回上一页面或多级页面,可以通过传递delta参数来指定返回的层级。\[2\]总结起来,navigateTo和redirectTo只能打开非tabbar页面,可传递参数;switchTab只能打开tabbar页面,不可传递参数;reLaunch可以打开任意页面,可传递参数。\[2\] #### 引用[.reference_title] - *1* [uniapp中页面跳转的几种方式及生命周期(整理)](https://blog.csdn.net/qq_38881495/article/details/126174382)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [uniapp页面跳转的几种方式](https://blog.csdn.net/m0_56144469/article/details/128559006)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [uni-app页面跳转](https://blog.csdn.net/weixin_49237787/article/details/115310620)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

往事不堪回首..

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值