首页 > 其他分享 >请求头获取用户设备、点赞

请求头获取用户设备、点赞

时间:2023-05-05 17:46:10浏览次数:29  
标签:lf style 请求 px 获取 tag 点赞 var op

请求头获取用户设备、点赞

请求头获取用户设备、点赞
一、GooGle浏览器:使用插件User Agent Switcher, URL sniffer 0.9.3.9或者使用User Agent Switcher,调整用户设备请求头
1.获取用户设备请求头的意义,QQ的空间动态,会有手机类型的显示,其实现原理就是获取设备的请求头文件,使用方法或正则匹配出来显示到用户的客户端;还可以通过进行判断让其再不同的终端中显示不同的页面,实现多终端多效果。

2.安装User Agent Switcher, URL sniffer 0.9.3.9方法有两种:

(1)谷歌内部应用商店安装,直接在谷歌应用商店搜索,添加到扩展程序中即可

(2)百度下载,下载到的文件后缀名是.crx 文件,使用时先把后缀名改成.rar或.zip的压缩包,然后解压导入创建好的文件夹,再以谷歌的拓展程序打开即可使用
后端展示代码块:此方式可以获得用户的请求头类型

    from django.core.handlers.wsgi import WSGIRequest
    print(request.environ)
    print(request.environ.get('HTTP_USER_AGENT'))

二、点赞效果

1.通过JQuery的使用实现动态的点赞效果图,主要涉及两个方法,dom中的document.createElement()方法添加span块,和setInterval设置时间动态显示

//javaScript部位代码块
$(function(){
    $(".zan").click(function(){
        var fz = 12; //font-size
        var tp = 5; //top
        var lf = 5; //left
        var op = 1; //opacity
        var tag = document.createElement("span");
        tag.innerHTML = "+1"; //因为是文本所以innerText与innerHtml的使用效果相同
        tag.style.color = "red";//字体颜色
        tag.style.fontSize = fz+ "px";//字体大小
        tag.style.top = lf + "px";//移动方向
        tag.style.opacity = op; //透明度
        $(this).append(tag);//把span标签添加到class属性值为zan的div的后面
        var tim = setInterval(function(){ //自动进行循环,直到条件达到clearInterval(tim)时停止
            fz += 5; //font-size
            tp += 5; //top
            lf += 5; //left
            op -= 0.2; //opacity
            tag.innerHTML = "+1";
            tag.style.color = "red";
            tag.style.fontSize = fz+ "px";
            tag.style.top = lf + "px";
            tag.style.opacity = op; //透明度
            if (op<0){ // 判定计时停止的条件
                clearInterval(tim);
                $("tag").remove();
            }

        },50)
        });
})


<!-- 全部代码块 -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/static/js/jquery-2.1.4.min.js"></script>
</head>
<style type="text/css">
    .item{
        height: 100px;
        border: 1px solid rebeccapurple;
    }
    .zan{
        height: 35px;
        width: 35px;
        background-color: #000000;
        color: white;
        position: relative;
        cursor: pointer;
    }
    .zan span{
        position: absolute;
        font-weight: bold;
    }
</style>

<div>
    <div class="item">
        <div class="zan">赞<span>+1</span></div>
    </div>
    <div class="item">
        <div class="zan">赞</div>
    </div>
    <div class="item">
        <div class="zan">赞</div>
    </div>
    <div class="item">
        <div class="zan">赞</div>
    </div>
</div>

<script>
    $(function(){
        $(".zan").click(function(){
            var fz = 12; //font-size
            var tp = 5; //top
            var lf = 5; //left
            var op = 1; //opacity
            var tag = document.createElement("span");
            tag.innerHTML = "+1"; //因为是文本所以innerText与innerHtml的使用效果相同
            tag.style.color = "red";//字体颜色
            tag.style.fontSize = fz+ "px";//字体大小
            tag.style.top = lf + "px";//移动方向
            tag.style.opacity = op; //透明度
            $(this).append(tag);//把span标签添加到class属性值为zan的div的后面
            var tim = setInterval(function(){ //自动进行循环,直到条件达到clearInterval(tim)时停止
                fz += 5; //font-size
                tp += 5; //top
                lf += 5; //left
                op -= 0.2; //opacity
                tag.innerHTML = "+1";
                tag.style.color = "red";
                tag.style.fontSize = fz+ "px";
                tag.style.top = lf + "px";
                tag.style.opacity = op; //透明度
                if (op<0){ // 判定计时停止的条件
                    clearInterval(tim);
                    $("tag").remove();
                }

            },50)
        });
    })
</script>
<body>
<!--
<form action="/userp/">
    <input type="text">
</form>
-->

</body>
</html>

标签:lf,style,请求,px,获取,tag,点赞,var,op
From: https://www.cnblogs.com/mengdie1978/p/17374901.html

相关文章

  • jquery获取input输入框中的值
    如何用javascript获取input输入框中的值HTML<inputtype="text"id="CSDN_NAME"name="CSDN_NAME"class="CSDN_NAME">一、jquery方法通过namevarname=$('input[name="CSDN_NAME"]').val();通过**id**varna......
  • 微信小程序获取头像、昵称的处理方法
    一、现象根据《小程序用户头像昵称获取规则调整公告》自2022年10月25日24时后(以下统称“生效期”),用户头像昵称获取规则将进行调整 :通过wx.getUserInfo接口获取用户头像将统一返回默认灰色头像,昵称将统一返回“微信用户”官方链接:https://developers.weixin.qq......
  • 1688|Taobao|JD京东api接口获取商品详情C++演示案例
    ​ 商品详情页的作用:介绍产品信息、给出购买理由、提升信任感、提出售后保障。1、介绍产品信息:产品信息表做得越完整,越能让用户更细致了解产品,也减少了售前客服咨询的工作量。2、给出购买理由:在用户初步了解了产品信息后,商家就需要展示商品优势,给出核心卖点。接下来小编会展......
  • post请求application/x-www-form-urlencoded
    importorg.springframework.http.HttpHeaders;importorg.springframework.http.MediaType;importorg.springframework.web.client.RestTemplateimportorg.springframework.util.MultiValueMap;importorg.springframework.util.LinkedMultiValueMap;importorg.springfra......
  • psutil获取CPU使用率总是为0的原因
    1.可能你获取的是测试脚本本身的CPU使用率,而测试脚本本身CPU占用率就很低,所以检测不出来;2.使用的是psutil.Process().cpu_percent(interval=interval),这个方法好像没有用。只能用替代方法:cpu_percent=psutil.cpu_percent(interval=interval) ......
  • C# 获取本地共享目录和网络共享目录
    1.在工程添加对应的cs文件usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.IO;usingSystem.Linq;usingSystem.Net;usingSystem.Runtime.InteropServices;usingSystem.Text;usingSystem.Web;......
  • 获取WebView发送给服务端的Accept-Language请求头
    1,WebView没有提供获取Accept-Language请求头的接口2,WebView的publicWebResourceResponseshouldInterceptRequest(WebViewview,WebResourceRequestrequest){}回调中WebResourceRequest不包含Accept-Language请求头,即使客户端向服务器端发送的请求中包含该请求头3,javascr......
  • .NET MAUI获取设备id
    参考:https://www.cnblogs.com/xd502djj/p/5799334.htmlhttps://blog.csdn.net/aaaym/article/details/126316223///<summary>///获取设备号///</summary>///<returns></returns>publicstaticstringGetAndroid......
  • php获取文章所有图片
    /***设置文章内容图片,上传到本地服务器处理*@param$content文章内容*@returnbool*/publicfunctionsetContentImg($content){//1.先正则匹配出所有的图片url$pattern='#<img(.+?)src\s*=\s*[\"|\']([^"|^\'......
  • [转]Java 获取操作系统的信息
    链接: https://blog.csdn.net/csdntoast/article/details/506398191获取本机的IP地址:privatestaticStringgetIpAddress()throwsUnknownHostException{InetAddressaddress=InetAddress.getLocalHost();returnaddress.getHostAddress();}......