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

推荐订阅源

P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
Jina AI
Jina AI
博客园_首页
宝玉的分享
宝玉的分享
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
T
Tailwind CSS Blog
雷峰网
雷峰网
Blog — PlanetScale
Blog — PlanetScale
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
月光博客
月光博客
罗磊的独立博客
F
Fortinet All Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
阮一峰的网络日志
阮一峰的网络日志
I
InfoQ
Simon Willison's Weblog
Simon Willison's Weblog
D
DataBreaches.Net
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Scott Helme
Scott Helme
B
Blog
M
MIT News - Artificial intelligence
K
Kaspersky official blog
H
Help Net Security
V
Vulnerabilities – Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
Engineering at Meta
Engineering at Meta
博客园 - 【当耐特】
L
Lohrmann on Cybersecurity
P
Privacy & Cybersecurity Law Blog
Project Zero
Project Zero
The Hacker News
The Hacker News
B
Blog RSS Feed
T
Tor Project 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界面