当前位置: 首页 > 编程日记 > 正文

JS实现复制到剪切板效果

微信小程序开发交流qq群   173683895

   承接微信小程序开发。扫码加微信。

代码:

<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" /><script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script><script src="https://cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script><title>领取兑换码</title><link rel="stylesheet" href="css/tiaoapp.css" /><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/tiaoapp.js"></script></head><body><div class="wai"><img src="img/wxbook/wxbook_bg.png" alt="" class="back_img"><p class="tip" id="copy"></p><p class="tit">复制兑换码,进入微信读书兑换</p><p class="box_tit">使用方式:</p><p class="mess">复制兑换码,然后打开 xxx 即会自动进入<br>活动页面领取福利</p><button class="box_button" onclick="tanchuan()" id="tankuang" data-clipboard-action="copy" data-clipboard-target="#copy">复制兑换码</button></div><div id="help" onclick="cancelHandle()"></div><div class="bg_kuang" id="kuang"><div class="groupAlert"><img class="attenion_icon" src="img/wxbook/wxBook.png" alt=""><p class="attenion_title">恭喜你!兑换成功</p><p class="attention_txt">如果已有“xxx”App,可登录后直接使用;</p><p class="attention_txt" style="margin-top: .2rem">如果没有“xxx”App,可以进入各大应用市场下载,下载后复制兑换码微信登录领取,更有惊喜红包赠送!</p></div><p class="attention_open_txt" onclick="submitFn()">确认</p></div></body><script>$(document).ready(function() {var targetText = $("#copy").text();var clipboard = new Clipboard('#tankuang');clipboard.on('success', function(e) {console.info('Action:', e.action);console.info('Text:', e.text);console.info('Trigger:', e.trigger);e.clearSelection();});});</script></html>

js代码:

window.onload = function() {var http_url ='https://xxx'var params = GetQueryString("params");var appid = GetQueryString("appid");console.log('params',params)var url = http_url+'/v1/xxx.do';var data = {params: params,appid: appid}$.post(url, data, function(result) {console.log('result', JSON.parse(result).body)if(JSON.parse(result).errCode=='0000'){$(".wai").html('很遗憾您来晚了一步,兑换码被抢光了');}else{$("#copy").html(JSON.parse(result).body);}});
}
function GetQueryString(name) {var LocString = String(window.document.location.href);var rs = new RegExp("(^|)" + name + "=([^&]*)(&|$)", "gi").exec(LocString), tmp;if (tmp = rs) {return decodeURI(tmp[2]);}// parameter cannot be foundreturn "";
}

相关文章:

如何管理多个Python版本和虚拟环境

Addition January 2019: If you are coming back to this blog after upgrading to macOS Mojave please see this github issue for a solution to the common pyenv ‘zlib not available’ problem.此外&#xff0c;2019年1月&#xff1a;如果在升级到macOS Mojave之后又回到…

linux 下byte,char,unsigned char的区别

在linux中&#xff0c;对byte的定义为无符号char&#xff0c;而char默认为有符号char。 #ifndef BYTE #define BYTE unsigned char #endif以下ZZ百度知道&#xff1a; 在C中&#xff0c;默认的基础数据类型均为signed&#xff0c;现在我们以char为例&#xff0c;说明(signed) c…

词法作用域和动态作用域

JavaScript采用的是词法作用域 1.词法作用域 即函数定义时&#xff0c;即确定的作用域。js中的作用域链&#xff0c;在函数声明时候&#xff0c;就已经确定了&#xff0c;无论函数在何处调用&#xff0c;其作用域变量的查找都是按照定义是包含关系去查找。 2.动态作用域 变量的…

10-18 JS基础复习笔记

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1.JS类型 Numbel String Boolean Symbol Null Undefined Object(Funtion,Array,Data,Regexp); 2.字符串转数字类型 "122" //122 var a 1 2; console.log(a) //3 3.null 和 u…

vue.js crud_如何使用VS Code和ADO.NET使用ASP.NET Core执行CRUD操作

vue.js crud介绍 (Introduction) In this article we are going to create a web application using ASP.NET Core MVC with the help of Visual Studio Code and ADO.NET. We will be creating a sample Employee Record Management System and performing CRUD operations on…

redis事物命令示例

命令示例&#xff1a; 1. 事务被正常执行&#xff1a;#在Shell命令行下执行Redis的客户端工具。/> redis-cli#在当前连接上启动一个新的事务。redis 127.0.0.1:6379>multiOK#执行事务中的第一条命令&#xff0c;从该命令的返回结果可以看出&#xff0c;该命令并没有立即执…

JS 函数 函数递归

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 重要&#xff1a;函数也是对象&#xff0c;你可以给它们添加属性或者更改它们的属性。 函数内部对象&#xff1a;arguments 解析&#xff1a;函数实际上是访问了函数体中一个名为 arguments 的内部对象…

swift设置启动图不现实_如何通过装饰房屋来开始在Swift中使用增强现实

swift设置启动图不现实by Ranadhir Dey由Ranadhir Dey 如何通过装饰房屋来开始在Swift中使用增强现实 (How to get started with augmented reality in Swift by decorating your home) If you’ve read my previous post, you already have a beautiful AR floor in your din…

可用于nodejs的SuperAgent(ajax API)

简单示例&#xff1a; import request from superagent;//引用声明 request.post(api).withCredentials()//跨域.end((err, res) > {if (res.ok) {const json JSON.parse(res.text);} else {console.log(获取失败);}}); 1、get 方式 当使用get请求传递查询字符串的时候&…

Java第四次实验

一、实验内容&#xff1a; 结对编程。运行TCP代码&#xff0c;结对进行&#xff0c;一人服务器&#xff0c;一人客户端&#xff1b;利用加解密代码包&#xff0c;编译运行代码&#xff0c;一人加密&#xff0c;一人解密&#xff1b; 集成代码&#xff0c;密后通过TCP发送。 二、…

JS 面向对象编程之原型(prototype)

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 function Person(first, last) {this.first first;this.last last; } Person.prototype.fullName function() {return this.first this.last; } Person.prototype.fullNameReversed function() {…

idea自动捕获_Smilefie:如何通过检测微笑来自动捕获自拍

idea自动捕获by Rishav Agarwal通过里沙夫阿加瓦尔 Smilefie&#xff1a;如何通过检测微笑来自动捕获自拍 (Smilefie: how you can auto-capture selfies by detecting a smile) Ten second takeaway: use Python and OpenCV to create an app that automatically captures a …

hiho 1015 KMP算法 CF 625 B. War of the Corporations

#1015 : KMP算法 时间限制:1000ms单点时限:1000ms内存限制:256MB描述 小Hi和小Ho是一对好朋友&#xff0c;出生在信息化社会的他们对编程产生了莫大的兴趣&#xff0c;他们约定好互相帮助&#xff0c;在编程的学习道路上一同前进。 这一天&#xff0c;他们遇到了一只河蟹&#…

React 组件绑定点击事件,并且传参完整Demo

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1.传数组下标给点击事件Demo&#xff1a; const A 65 // ASCII character codeclass Alphabet extends React.Component {constructor(props) {super(props);this.handleClick this.handleClick.bind…

ScaleYViewPager

https://github.com/eltld/ScaleYViewPager 转载于:https://www.cnblogs.com/eustoma/p/4572925.html

node mongoose_如何使用Express,Mongoose和Socket.io在Node.js中构建实时聊天应用程序

node mongooseby Arun Mathew Kurian通过阿伦马修库里安(Arun Mathew Kurian) 如何使用Express&#xff0c;Mongoose和Socket.io在Node.js中构建实时聊天应用程序 (How to build a real time chat application in Node.js using Express, Mongoose and Socket.io) In this tut…

结对项目开发电梯调度 - 整体设计

一、系统介绍 1&#xff0e; 功能描述 本电梯系统用来控制一台运行于一个具有16层的大楼电梯&#xff0c;它具有上升、下降、开门、关门、载客的基本功能。 大楼的每一层都有&#xff1a; (1) 两个指示灯: 这两个指示灯分别用于指示当前所在的层数和电梯的当前状态&#xff…

3.分支结构与循环结构

1 程序结构 程序结构分为顺序结构、分支结构、循环结构。分支结构有&#xff1a;if结构&#xff0c;if....else结构&#xff0c;if...else if....else &#xff0c;if...else结构&#xff0c;switch结构&#xff1b;循环结构有&#xff1a;while循环&#xff0c;do....while循环…

微信小程序 实现复制到剪贴版功能

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 实现API&#xff1a; wx.setClipboardData(Object object) API说明&#xff1a;设置系统剪贴板的内容 属性类型默认值是否必填说明支持版本datastring 是剪贴板的内容 successfunction 否接口调用成功…

数据结构面试题编程题_您下次编程面试时应该了解的顶级数据结构

数据结构面试题编程题by Fahim ul Haq通过Fahim ul Haq Niklaus Wirth, a Swiss computer scientist, wrote a book in 1976 titled Algorithms Data Structures Programs.瑞士计算机科学家Niklaus Wirth在1976年写了一本书&#xff0c;名为《 算法数据结构程序》。 40 yea…

oracle使用小技巧

批量禁用触发器 SELECT ALTER TRIGGER || trigger_name || DISABLE; FROM all_triggers; 这样就生成了一个禁用语句列表&#xff0c;复制到sql脚本执行界面&#xff0c;批量执行即可&#xff0c;类似的&#xff0c;可以用all_tables来批量删除表。 转载于:https://www.cnblogs…

if for switch语句

顺序语句&#xff1a;一行行执行条件语句:选择分支if语句 1、 if&#xff08;....&#xff09;//括号内是判断条件 { //程序代码&#xff0c;运算等等 } 2、 if&#xff08;....&#xff09;//括号内是判断条件 { //程序代码&#xff0c;运算等等 } else//如果不满足条件则执…

Apache Unable to find the wrapper https - did you forget to enable it when you configured PHP?

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 Apache Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? 问题解决办法&#xff1a; 打开配置文件 php.ini &#xff0c; 如图&#xff1a; …

文件魔术数字_如何使用魔术脚手架自动创建文件并节省时间

文件魔术数字Before we begin: This article uses JavaScript / Node.js example code, but you can port these concepts to any language using the right tools.开始之前&#xff1a;本文使用JavaScript / Node.js示例代码&#xff0c;但是您可以使用正确的工具将这些概念移…

Sql Server统计报表案例

场景&#xff1a;查询人员指定年月工作量信息 USE [Test] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[GetWorkLoadMain] year int, month int, UserId varchar(50) as begindeclare day varchar(50)set dayCAST(year as varchar)-RIGHT((00…

运行报表时提示输入用户名和密码

在AX2012运行报表是总是提示用户输入用户名和密码&#xff1a; 尝试输入登陆名和密码&#xff0c;点击查看报表&#xff0c;出现如下错误&#xff1a; 因为AX2012的报表使用的针对AX2012客制化的SSRS&#xff0c;而要求输入登录名和密码是SSRS报表的数据源设置导致的。在SSRS管…

CSS 文字,边框实现从左至右颜色渐变

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 1.文本从左至右颜色渐变 效果图&#xff1a; 2.边框从左至右颜色渐变 效果图&#xff1a; 实现代码&#xff1a; 1.文本从左至右颜色渐变实现代码&#xff1a; <!DOCTYPE html> <html>&l…

如何使用Create-React-App和自定义服务人员构建PWA

Note: This is not a primer on create-react-app or what a service worker is. This post assumes prior knowledge of both.注意&#xff1a;这不是create-react-app或服务工作者的入门。 这篇文章假定两者都有先验知识。 So, I recently had the opportunity to work on a…

inline-block空隙怎么解决

方法一&#xff1a;移除空格 元素间留白间距出现的原因就是标签段之间的空格&#xff0c;因此&#xff0c;去掉HTML中的空格&#xff0c;自然间距就木有了。考虑到代码可读性&#xff0c;显然连成一行的写法是不可取的&#xff0c;我们可以&#xff1a; <div class"spa…

php 网络请求 get请求和post请求

微信小程序开发交流qq群 173683895 承接微信小程序开发。扫码加微信。 代码记录 <?php header(content-type:application:json;charsetutf8); header(Access-Control-Allow-Origin:*); //header(Access-Control-Allow-Methods:POST); header(Access-Control-Allow-He…