【 认真工作,享受生活 】

笑中千关过,愁内百事哀,争胜是祸,繁华似梦,平淡是福。
随笔 - 57, 文章 - 0, 评论 - 12, 阅读 - 11万
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

JS控制的几种页面跳转方式和传值

Posted on   qiqi  阅读(1365)  评论(0编辑  收藏  举报
  汇集JS控制的几种页面跳转方式和传值,从好友博客转载的!
 
第一种:
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>

第二种:
<script language="javascript">
alert("返回");
window.history.back(-1);
</script>


第三种:
<script language="javascript">
window.navigate("top.jsp");
</script>

第四种:
<script language="JavaScript">
self.location=''top.htm'';
</script>

第五种:
<script language="javascript">
alert("非法访问!");
top.location=''xx.jsp'';

</script>  

第六种:

遇到一个兄弟说要打开一个新的页面,原页面不关闭,还要传服务器端的数据,呵呵呵,帮他弄了一下:

页面的代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>ceshi</title>

    <script language="javascript" type="text/javascript">

    function change()

    {

   var str1=document.getElementById("TextBox1").value;

    window.open("Default2.aspx?id="+str1,"_blank",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=260,left=300,top=300');

     }

    </script>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

        

        <input id="Button2" type="button" value="button" onclick="change()" />

        <input id="Reset1" type="reset" value="reset" /></div>

    </form>

</body>

</html>

服务器端的代码:

 public string str = "";

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!this.IsPostBack)

        {

            str = "panjun";

            this.TextBox1.Text = str;

        }

    }

这样就好了!!

编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示