最近在项目中看到这样一种效果——点击当前网页文本框,然后弹出一个缩小的网页,并在网页里选择或填写数据,然后又返回当前网页,小网页关闭。感觉非常不错,其实在以前网上也看见过,只是当时没有留心。今天抽时间把它从项目中提炼出来,给自己做一个笔记,以备下次只需。不废话了。

第一步新建两个页面分别取名为A.html,B.html.

第二步编写页面代码如下

A.html页面

<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>demoA页面</title>
<script type="text/javascript">
function PopBreakfast(obj) {
var returnValue = window.showModalDialog("B.html", obj, "dialogWidth=300px;dialogHeight=150px");
alert(returnValue);
if (returnValue) {
obj.value = returnValue;
} }
</script>
</head>
<body>
<form id="form1" action="">
<table>
<tr>
<td>城市</td>
<td><input type="text" id="txtcity" onclick="PopBreakfast(this)"/></td>
<td>地址</td>
<td><input type="text" id="txtaddress" onclick="PopBreakfast(this)"/></td>
</tr>
</table>
</form>
</body>
</html>

B.html页面

<html>
<head>
<title>demoB页面</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
body
{
font-size: 12px;
font-family: arial;
}
select, input
{
padding: 0px;
margin: 0px;
}
#content-wrapper
{
margin: 20px 0px 20px 20px;
}
#content-wrapper td
{
text-align: left;
padding: 2px;
}
#content-wrapper td.title
{
font-weight: bold;
}
input.city
{
width: 180px;
}
select.city
{
width: 180px;
}
.confirm-btn
{
padding: 2px;
}
</style>
<script type="text/javascript">
function Confirm() {
var selectValue = document.getElementById("selectcity").value;
var inputValue = document.getElementById("txtaddress").value;
if (inputValue.length > 0) {
window.returnValue = inputValue;
} else {
window.returnValue = selectValue;
}
alert(window.returnValue);
window.close();
} window.onclose = function () {
window.returnValue = "";
}
</script>
</head>
<body>
<form id="form2" >
<center>
<div id="content-wrapper">
<table cellpadding="0" cellspacing="0" width="250px">
<tr>
<td class="title">
选择城市
</td>
</tr>
<tr>
<td>
<select id="selectcity" class="city">
<option value="">-- Select --</option>
<option value="北京">北京</option>
<option value="广州">广州</option>
<option value="上海">上海</option>
<option value="香港">香港</option>
</select>
</td>
</tr>
<tr>
<td>
<input id="txtaddress" type="text" class="city" />
</td>
</tr>
<tr>
<td>
<input type="button" value="Confirm" onclick="Confirm()" class="confirm-btn" />
</td>
</tr>
</table>
</div>
</center>
</form>
</body>
</html>

第三步测试,结果如下图:

开始页面A

点击后弹出窗体效果图:

选中填写之后的效果:

经测试必须 在iis里或vs里运行才可以看到效果,否则有跨域错误。

错误提示:Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.

好了,这也算是一个新的开始吧。

还有另外一种方法

再有另外一种方法

web跨页弹窗选值的更多相关文章

  1. A在SP.NET跨页多选

    在ASP.NET跨页多选 本文介绍怎样在ASP.NET中实现多页面选择的问题.其详细思路非常easy:用隐藏的INPUT记住每次选择的项目,在进行数据绑定时.检查保存的值,再在DataGrid中进行选 ...

  2. Bootstrap table 跨页全选

    此代码是针对于bootstrap table中分页的跨页全选. 以下是整个bootstrap的定义 <script type="text/javascript" src=&q ...

  3. Element UI表格组件技巧:如何简洁实现跨页勾选、跨页统计功能

    业务场景 在使用Element UI的Table组件时,常常面对这样的业务需求: 表格数据的每一项都要提供勾选框,当切换分页时,能够记忆所有页面勾选的数据,以实现批量提交不同页面勾选数据的功能.并且, ...

  4. element ui表格常用功能如:导出 新增 删除 多选 跨页多选 固定表头 多级表头 合并行列 等常见需求

    <template> <div class="table-cooperte"> <el-table :data="tableData&quo ...

  5. layui table 跨页记忆选择

    layui 表格功能目前默认不支持跨页记忆选择 下面来实现layui table跨页记忆选择实现 基于layui版本 1.4.5 表格跨页通用方法 //表格分页复选框 layui.define(['j ...

  6. 每日学习心得:Js获取Checkboxlist所选值、instanceof 和typeof区别、为Array添加contains方法

    2013-11-24 前言: 上周在工作中遇到了一些跟JS以及前台交互的问题,虽然算不上多么高深,但是在解决时也走了一些弯路,所以就总结一下. 1.    JS获取checkboxList所选的值 这 ...

  7. 要在一般处理程序中获取其他页面的session值

    1.要在一般处理程序中获取其他页面的session值,需要引用名空间: using System.Web.SessionState; 2.然后继承一个接口:IRequiresSessionState, ...

  8. Candence下对“跨页连接器(off-page connector)”进行批量重命名的方法

    parts.ports.alias等等均可以在“属性编辑器(Property Editor)”中进行查看编辑,并通过复制到Excel等表格软件来进行批量修改.之后再粘贴回去的方法进行批量编辑.但是“跨 ...

  9. Web跨浏览器进程通信(Web跨域)

    Web跨域已是老生常谈的话题,这次来尝试下跨域浏览器进程之间的通信 —— 这在过去基本依靠网络中转实现   在之前一篇文章里尝试了跨浏览器的数据共享,最后提到使用LocalConnection还可以实 ...

随机推荐

  1. Windows-009-Win7 操作系统安装图文详解

    此文主要讲述 Win7 操作系统的安装,配以详细的图文介绍,希望能对亲有所帮助,若有不足之处,敬请大神指正,不胜感激! 若是亲在虚拟机(VirtualBox)中安装 Win7,其前期虚拟硬件系统的操作 ...

  2. web系统权限设计

    应该有七张表 1.appSystem 表: 主要在多系统中的 统一权限管理:主要就是系统的URL USE [Star_Permission] GO /****** 对象: Table [dbo].[A ...

  3. Insert BLOB && CLOB from PL/SQL and JDBC

    For PL/SQL 1)Create Directory Where BLOB resides. create or replace directory temp as '/oradata2'; - ...

  4. Ubuntu 安装 Brother MFC7470D 驱动

    Ubuntu 安装 Brother MFC7470D 驱动 办公室的打印机是 Brother MFC7470D ,在 Ubuntu 中安装打印机驱动时,发现没有这个型号的驱动.只有 MFC7450 的 ...

  5. Java开发遇到的问题及解决方案

    一.java.lang.OutOfMemoryError 问题:myeclipse 内存不足,又显示内存溢出等问题怎么回事?( java.lang.OutOfMemoryError: PermGen ...

  6. dojo使用疑难杂症集锦

    最近在用dojo做项目, 把使用过程中遇到的一些问题记录下来, 方便以后查阅, 因为问题不断, 所以持续更新中.......... 嵌套 TabContainer 时会出现样式问题: tab控制样式问 ...

  7. Can't add self as subview的困惑

    2016-05-27 09:40:43.4043 UMLOG: event: session_id=B63F36D84AD478B9F95C7D0F05DD819B, event=user_choos ...

  8. jQuery中append()与appendTo()方法区别

    1. append(content)方法 方法作用:向每个匹配的元素内部追加内容. 参数介绍:content (<Content>): 要追加到目标中的内容. 用法示例: HTML代码为& ...

  9. mysql参数sql_log_bin

    如果想在主库上执行一些操作,但不复制到slave库上,可以通过修改参数sql_log_bin来实现. 比如想在主库上修改某个表的定义,但是在slave库上不做修改: master mysql> ...

  10. Test4J与Jtester单元测试常用注解比较

    package com.alibaba.ceres.catalog.biz.product.impl; import org.junit.After; import org.junit.Before; ...