web跨页弹窗选值
最近在项目中看到这样一种效果——点击当前网页文本框,然后弹出一个缩小的网页,并在网页里选择或填写数据,然后又返回当前网页,小网页关闭。感觉非常不错,其实在以前网上也看见过,只是当时没有留心。今天抽时间把它从项目中提炼出来,给自己做一个笔记,以备下次只需。不废话了。
第一步新建两个页面分别取名为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跨页弹窗选值的更多相关文章
- A在SP.NET跨页多选
在ASP.NET跨页多选 本文介绍怎样在ASP.NET中实现多页面选择的问题.其详细思路非常easy:用隐藏的INPUT记住每次选择的项目,在进行数据绑定时.检查保存的值,再在DataGrid中进行选 ...
- Bootstrap table 跨页全选
此代码是针对于bootstrap table中分页的跨页全选. 以下是整个bootstrap的定义 <script type="text/javascript" src=&q ...
- Element UI表格组件技巧:如何简洁实现跨页勾选、跨页统计功能
业务场景 在使用Element UI的Table组件时,常常面对这样的业务需求: 表格数据的每一项都要提供勾选框,当切换分页时,能够记忆所有页面勾选的数据,以实现批量提交不同页面勾选数据的功能.并且, ...
- element ui表格常用功能如:导出 新增 删除 多选 跨页多选 固定表头 多级表头 合并行列 等常见需求
<template> <div class="table-cooperte"> <el-table :data="tableData&quo ...
- layui table 跨页记忆选择
layui 表格功能目前默认不支持跨页记忆选择 下面来实现layui table跨页记忆选择实现 基于layui版本 1.4.5 表格跨页通用方法 //表格分页复选框 layui.define(['j ...
- 每日学习心得:Js获取Checkboxlist所选值、instanceof 和typeof区别、为Array添加contains方法
2013-11-24 前言: 上周在工作中遇到了一些跟JS以及前台交互的问题,虽然算不上多么高深,但是在解决时也走了一些弯路,所以就总结一下. 1. JS获取checkboxList所选的值 这 ...
- 要在一般处理程序中获取其他页面的session值
1.要在一般处理程序中获取其他页面的session值,需要引用名空间: using System.Web.SessionState; 2.然后继承一个接口:IRequiresSessionState, ...
- Candence下对“跨页连接器(off-page connector)”进行批量重命名的方法
parts.ports.alias等等均可以在“属性编辑器(Property Editor)”中进行查看编辑,并通过复制到Excel等表格软件来进行批量修改.之后再粘贴回去的方法进行批量编辑.但是“跨 ...
- Web跨浏览器进程通信(Web跨域)
Web跨域已是老生常谈的话题,这次来尝试下跨域浏览器进程之间的通信 —— 这在过去基本依靠网络中转实现 在之前一篇文章里尝试了跨浏览器的数据共享,最后提到使用LocalConnection还可以实 ...
随机推荐
- windows下安装yaf和git
不得不说win7下安装yaf比mac下安装yaf简单多了 1. phpinof()看一下你的php版本.我的是php 5.4所以我选择是php_yaf-2.1.9-x86-5.4-zts-nodebu ...
- 《JAVA NIO》Channel
3.通道 Channle主要分为两类:File操作对应的FIleChannel和Stream操作对应的socket的3个channe. 1.这3个channel都是抽象类.其具体实现在SPI里面. 2 ...
- jquery选择器效率优化问题
jquery选择器效率优化问题 jquery选择器固然强大,但是使用不当回导致效率问题: 1.要养成将jQuery对象缓存进变量的习惯 //不好的写法 $('#btn').bind("c ...
- 破解Mysql数据库密码
破解Mysql数据库密码 点我,点我,破解mysql数据库密码:
- C++ version the delaunay triangulation
https://github.com/Bl4ckb0ne/delaunay-triangulation
- Vue 模板
界面: html: @using Abp.Web.Mvc.Extensions @{ ViewBag.CurrentPage = "BasicDatas"; } @section ...
- 一个WebService Demo
1.建立一个Asp.net Web网站,添加新项Web服务MyMath.asmx.编写如下代码: using System; using System.Collections.Generic; usi ...
- Java IO 写文件
package com.lf.fileproject; import java.io.File; import java.io.FileOutputStream; import org.junit.T ...
- SWING
第一个图形界面应用程序.图形用户界面简称GUI(Graphical User Interface),通过GUI用户可以更好地与计算机进行交互.Swing简介Swing工具包提供了一系列丰富的GUI 组 ...
- android studio ,Gradle DSL method not found: 'compile()'
用gradle构建android工程出现 Gradle DSL method not found: 'compile()' 错误 检查你外层的build.gradle文件中是不是用了compile方 ...