惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V2EX - 技术
V2EX - 技术
L
LangChain Blog
IT之家
IT之家
S
SegmentFault 最新的问题
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
U
Unit 42
B
Blog RSS Feed
GbyAI
GbyAI
Microsoft Security Blog
Microsoft Security Blog
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
C
CERT Recently Published Vulnerability Notes
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
Vercel News
Vercel News
S
Schneier on Security
Spread Privacy
Spread Privacy
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
博客园 - 叶小钗
雷峰网
雷峰网
博客园_首页
人人都是产品经理
人人都是产品经理
P
Palo Alto Networks Blog
The Hacker News
The Hacker News
T
Tor Project blog
L
Lohrmann on Cybersecurity
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cybersecurity and Infrastructure Security Agency CISA
P
Privacy International News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tenable Blog
V
Vulnerabilities – Threatpost
大猫的无限游戏
大猫的无限游戏
博客园 - 【当耐特】
V
V2EX
Security Latest
Security Latest
A
About on SuperTechFans
Cloudbric
Cloudbric
S
Security Affairs
MongoDB | Blog
MongoDB | Blog
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
TaoSecurity Blog
TaoSecurity Blog

博客园 - soulsjie

一种在winfrom窗体中显示计算公式的解决方案 winform窗体DataGridView合并单元格处理 C#GDI+阴影笔刷样式HatchStyle探讨 C#代码混淆工具ConfuserEx的使用 Aspose.Words在指定位置插入图片、调整图片大小 C#获取对象实体的键值对信息 C#将Winform上的TextBox和ComBox的值导入和导出 C#使用Aspose.Words将Spread表格插入到Word中 C# Aspose.Words将word中自定义的标签进行替换 Python文件操作基础方法 C# 将项目资源文件保存到磁盘上 SqlSugar数据库辅助类 使用存储过程备份MS SQLServer数据库 案例3:JAVA GUI 随机点名程序 案例2:JAVA GUI 简易计算器 ArcGIS JS API 添加要素图层 点击时获取图层属性 ArcGIS JS API 将天地图设置为底图 SqlSugar各数据库连接串 案例1:JAVAGUI用户管理
HTML5PLUS实现类似右侧弹出菜单
soulsjie · 2022-08-28 · via 博客园 - soulsjie

一、实现效果

使用【plus.webview】对象实现右侧弹出菜单栏:

点击菜单图标弹出菜单列表,点击页面其它地方或点击【关闭菜单】收缩菜单。

二、源码

index.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <title></title>
    <script type="text/javascript">
   		document.addEventListener('plusready', function(){
   			//console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。")
   		});
    </script>
</head>
<body>
	<div style="width: 100%;height: 60px;background: #eee;">
		<div style="float: right;height: 60px;line-height: 60px; margin-right: 10px;font-size: 25px;" onclick="OpenMenu()">
			<span class="glyphicon glyphicon-tasks"></span>
		</div>	
	</div>
</body>
<script type="text/javascript">
	function OpenMenu(){
		var curr=plus.webview.currentWebview();
		var menu=plus.webview.create("pages/Menu.html","menu",{"width":"40%","left":"60%","top":"62px"});
		curr.setStyle({
			mask:"rgba(0,0,0,0)"
		});
		curr.addEventListener("maskClick",function(){
			curr.setStyle({
				mask:"none"
			});
			menu.close();
		});
		menu.show("zoom-fade-out",200);
	}
</script>
</html>

  菜单界面:pages/Menu.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
	<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
	<title></title>
    <script type="text/javascript">
    	
   		document.addEventListener('plusready', function(){
   			//console.log("所有plus api都应该在此事件发生后调用,否则会出现plus is undefined。")
   			
   		});
   		
    </script>
</head>
<body>
	<div style="margin-right: 5px;background: #4c4c4c;border-radius: 5px;">
		<ul>
			<li><span class="glyphicon glyphicon-comment"></span> 发起群聊</li>
			<li><span class="glyphicon glyphicon-user"></span> 添加朋友</li>
			<li><span class="glyphicon glyphicon-camera"></span> 扫一扫</li>
			<li><span class="glyphicon glyphicon-folder-open"></span> 收付款</li>
			<li onclick="BackIndex()"><span class="glyphicon glyphicon-comment"></span> 关闭菜单</li>
		</ul>
	</div>
	<style>	
	li{
		font-size: 12pt;
		cursor: pointer;
		height: 50px;
		color: #fff;
		line-height: 50px;
		border-bottom: 1px solid #5d5d5d;
		list-style-type: none;
	}
	</style>
    <script type="text/javascript">
		function BackIndex(){
			var menu=plus.webview.currentWebview();
			var index=menu.opener();
			menu.close();
			index.setStyle({
				mask:"none"
				});
		}
	</script>
</body>
</html>

 三、关键方法 

plus.webview.currentWebview();//获取当前webview对象

webviewObj.opener();//获取创建当前webview的webview对象

webviewObj.setStyle();//设置webview对象的样式

webviewObj.close();//关闭webview界面

webviewObj.show();//显示webview界面