主要代码:

注意这段代码 是子页面中添加的也就是弹出的那个页面刷新父页面

   <script type="text/javascript">

        function shuaxin() {
try {
window.parent.opener.location.reload();
window.parent.close();
} catch (e) {
window.parent.opener.location = "http://localhost:32859/test.aspx";
window.parent.opener = null;
window.parent.close();
}
} </script>

测试demo

首先新建一个web1,再新建一个test.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="WebApp02.test" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title> <script type="text/javascript"> function OpenPage() { window.open('http://localhost:32858/testweb2.aspx', 'newwindow', 'height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no') }
</script>
</head>
<body>
<form id="form1" runat="server">
<div> <asp:Label ID="lblTest" runat="server" Text="还没开始测试"></asp:Label>
<input id="Button1" type="button" value="button" onclick="OpenPage()" /> </div>
</form>
</body>
</html>

test.aspx 后台代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; namespace WebApp02
{
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
lblTest.Text = "页面执行时间:" + DateTime.Now.ToLocalTime();
}
Load();
} public void Load()
{
lblTest.Text = "页面执行时间:" + DateTime.Now.ToLocalTime();
} }
}

再次新建一个web2,再新建一个testweb2.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="testweb1.aspx.cs" Inherits="WebApp01.testweb1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title> <script type="text/javascript"> function shuaxin() {
try {
window.parent.opener.location.reload();
window.parent.close();
} catch (e) {
window.parent.opener.location = "http://localhost:32859/test.aspx";
window.parent.opener = null;
window.parent.close();
}
} </script> </head>
<body>
<form id="form1" runat="server">
<div>
<input id="Text1" type="button" value="关闭当前页面" onclick="shuaxin()" />
</div>
</form>
</body>
</html>

参考文章:http://www.xuebuyuan.com/838707.html

js 执行跨域刷新页面的更多相关文章

  1. js执行跨域请求

    //js执行跨域请求 var _script = document.createElement('script'); _script.type = "text/javascript" ...

  2. js&jquery跨域详解jsonp,jquery并发大量请求丢失回调bug

    URL  说明 是否允许通信 http://www.a.com/a.js http://www.a.com/b.js 同一域名下 允许 http://www.a.com/lab/a.js http:/ ...

  3. JS JSOP跨域请求实例详解

    JSONP(JSON with Padding)是JSON的一种“使用模式”,可用于解决主流浏览器的跨域数据访问的问题.这篇文章主要介绍了JS JSOP跨域请求实例详解的相关资料,需要的朋友可以参考下 ...

  4. JS Ajax跨域访问

    js ajax跨域访问报"No 'Access-Control-Allow-Origin' header is present on the requested resource 如果请求的 ...

  5. js调用跨域

    web aapi 初体验 解决js调用跨域问题   跨域界定 常见跨域: 同IP不同端口: http:IP:8001/api/user     http:IP:8002/api/user 不同IP不同 ...

  6. react-native debug js remotely跨域问题

    react-native debug js remotely跨域问题 我们在安卓真机上调试react-native时,启用debug js remotely的时候,会出现跨域问题.这个时候我们只需要一 ...

  7. 静态页面调试JS出现跨域问题

    在chrome浏览器或者firefox浏览器里,由于安全限制的原因,本地调试JS,如果不配服务器环境而直接打开页面,那所有的AJAX操作会抛出下面错误: XMLHttpRequest cannot l ...

  8. 搞懂:前端跨域问题JS解决跨域问题VUE代理解决跨域问题原理

    什么是跨域 跨域:一个域下的文档或脚本试图去请求另一个域下的资源 广义的跨域包含一下内容: 1.资源跳转(链接跳转,重定向跳转,表单提交) 2.资源请求(内部的引用,脚本script,图片img,fr ...

  9. 后台访问 JS解决跨域问题

    今天看了看以前做的一个小项目(其实就是一个页面),分享一下当时解决跨域问题的: 背景:公司把项目部署在多台服务器上,防止一台服务器崩溃后,其他的可以继续访问,对应本公司来说,某台服务器出问题后,技术人 ...

随机推荐

  1. 【BZOJ4345】[POI2016]Korale 堆(模拟搜索)

    [BZOJ4345][POI2016]Korale Description 有n个带标号的珠子,第i个珠子的价值为a[i].现在你可以选择若干个珠子组成项链(也可以一个都不选),项链的价值为所有珠子的 ...

  2. 【BZOJ4566】[Haoi2016]找相同字符 后缀数组+单调栈

    [BZOJ4566][Haoi2016]找相同字符 Description 给定两个字符串,求出在两个字符串中各取出一个子串使得这两个子串相同的方案数.两个方案不同当且仅当这两 个子串中有一个位置不同 ...

  3. JAVA 集合相关整理和学习

    一.Set接口实现类 二.List接口实现类 三.Queue接口实现类 四.Map接口实现类 五.上面的图片截自附件: 附件列表

  4. Centos6.5下Samba服务器的安装和配置

    1.安装samba服务 # yum install samba samba-client samba-swat 2.安装包说明 samba-3.6.23-43.el6_9.x86_64----> ...

  5. Powershell Get Domain Group的几种方法

    Group常见属性介绍: 一.Get-ADGroup获取群组(如下例循环获取群组的发送权限) #群组的发送权限info $groups=Get-ADGroup -filter * -SearchSco ...

  6. GO语言中使用OpenCV

    GO语言中使用OpenCV - OpenCV China :图像处理,计算机视觉库,Image Processing, Computer Vision http://wiki.opencv.org.c ...

  7. MyBatis generator 生成生成dao model mappper

    MyBatis GeneratorXML配置文件参考 在最常见的用例中,MyBatis Generator(MBG)由XML配置文件驱动. 配置文件告诉MBG: 如何连接到数据库 什么对象要生成,以及 ...

  8. MongoDB-5: 查询(游标操作、游标信息)

    一.简介 db.collection.find()可以实现根据条件查询和指定使用投影运算符返回的字段省略此参数返回匹配文档中的所有字段.并返回到匹配文档的游标,可以随意修改查询限制.跳跃.和排序顺序的 ...

  9. KMP算法最浅显理解——一看就明确

    说明 KMP算法看懂了认为特别简单,思路非常easy,看不懂之前.查各种资料,看的稀里糊涂.即使网上最简单的解释,依旧看的稀里糊涂. 我花了半天时间,争取用最短的篇幅大致搞明确这玩意究竟是啥. 这里不 ...

  10. 利用反射快速给Model实体赋值

    试想这样一个业务需求:有一张合同表,由于合同涉及内容比较多所以此表比较庞大,大概有120多个字段.现在合同每一次变更时都需要对合同原始信息进行归档一次,版本号依次递增.那么我们就要新建一张合同历史表, ...