js页面加水印防复制防另存为代码(纯js)

这段代码是给前端页面添加水印的代码..何为水印?是可以显示登录人的姓名也可以定制一些内容等...代码如下:

前提是得引用下面两个js  可以去下载引入

<html>
<head>
    <script src="jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="jquery.watermark.js" type="text/javascript"></script>
    <style type="text/css">
        tbody#t_body tr{background:transparent;}
        .soso_selsect table tr{background:transparent;}
        input{background:transparent;}
        select{background:transparent;}
        textarea{background:transparent;}
    </style>

    <script type="text/javascript">

        //禁止复制和右键另存为
        function iEsc() { return false;}
        function iRec() { return true;}
        function DisableKeys() {
            if (event.ctrlKey || event.shiftKey || event.altKey) {
                window.event.returnValue = false;
                iEsc();
            }
        }
        document.ondragstart = iEsc;
        document.onkeydown = DisableKeys;
        document.oncontextmenu = iEsc;
        if (typeof document.onselectstart != "undefined")
            document.onselectstart = iEsc;
        else {
            document.onmousedown = iEsc;
            document.onmouseup = iRec;
        }


        //添加水印
        function addImage(){
            var managerName = "水印";
            $('body').watermark({
                texts : [managerName], //水印文字
                textColor : "#BFBFBF", //文字颜色
                textFont : '16px 微软雅黑', //字体
                width : 100, //水印文字的水平间距
                height : 100,  //水印文字的高度间距(低于文字高度会被替代)
                textRotate : -30 //-90到0, 负数值,不包含-90
            });
        }
    </script>
</head>
<body onload="addImage()">
<p align="center">成绩表</p>
<table border="2px" align="center" bordercolor="blue" width="600px" height="300px">
    <tr align="center">
        <td>项目</td>
        <td colspan="5" >上课</td>
        <td colspan="2" >休息</td>
    </tr>
    <tr align="center">
        <td>星期</td>
        <td>星期一</td>
        <td>星期二</td>
        <td>星期三</td>
        <td>星期四</td>
        <td>星期五</td>
        <td>星期六</td>
        <td>星期日</td>
    </tr>
    <tr align="center">
        <td rowspan="4">上午</td>
        <td>语文</td>
        <td>数学</td>
        <td>英语</td>
        <td>英语</td>
        <td>物理</td>
        <td>计算机</td>
        <td rowspan="4">休息</td>
    </tr>
    <tr align="center">
        <td>数学</td>
        <td>数学</td>
        <td>地理</td>
        <td>历史</td>
        <td>化学</td>
        <td>计算机</td>
    </tr>
    <tr align="center">
        <td>化学</td>
        <td>语文</td>
        <td>体育</td>
        <td>计算机</td>
        <td>英语</td>
        <td>计算机</td>
    </tr>
    <tr align="center">
        <td>政治</td>
        <td>英语</td>
        <td>体育</td>
        <td>历史</td>
        <td>地理</td>
        <td>计算机</td>
    </tr>
    <tr align="center">
        <td rowspan="2">下午</td>
        <td>语文</td>
        <td>数学</td>
        <td>英语</td>
        <td>物理</td>
        <td>计算机</td>
        <td>英语</td>
        <td rowspan="2">休息</td>
    </tr>
    <tr align="center">
        <td>数学</td>
        <td>数学</td>
        <td>地理</td>
        <td>历史</td>
        <td>化学</td>
        <td>计算机</td>
    </tr>
</table>
</body>
</html>

效果如下:

Demo下载地址:https://download.csdn.net/download/zxd8080666/10558467

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Ffmpeg是一个功能强大的视频处理工具,可以通过在视频中添加水印来保护视频内容的版权,以下是使用C语言实现在视频中添加水印的步骤: 1.打开视频文件 ```c AVFormatContext *fmt_ctx = avformat_alloc_context(); if(avformat_open_input(&fmt_ctx, "input.mp4", NULL, NULL) < 0) { printf("无法打开输入文件\n"); exit(1); } ``` 2.查找视频流 ```c if(avformat_find_stream_info(fmt_ctx, NULL) < 0) { printf("无法查找视频流信息\n"); exit(1); } int video_index = -1; for(int i=0; i<fmt_ctx->nb_streams; i++) { if(fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { video_index = i; break; } } if(video_index == -1) { printf("无法找到视频流\n"); exit(1); } AVCodecParameters *codec_par = fmt_ctx->streams[video_index]->codecpar; ``` 3.打开视频解码器 ```c AVCodec *codec = avcodec_find_decoder(codec_par->codec_id); if(codec == NULL) { printf("无法找到解码器\n"); exit(1); } AVCodecContext *codec_ctx = avcodec_alloc_context3(codec); if(avcodec_parameters_to_context(codec_ctx, codec_par) < 0) { printf("无法将解码器参数转换为上下文\n"); exit(1); } if(avcodec_open2(codec_ctx, codec, NULL) < 0) { printf("无法打开解码器\n"); exit(1); } ``` 4.创建输出文件 ```c AVFormatContext *out_fmt_ctx = NULL; if(avformat_alloc_output_context2(&out_fmt_ctx, NULL, NULL, "output.mp4") < 0) { printf("无法创建输出文件\n"); exit(1); } AVStream *out_stream = avformat_new_stream(out_fmt_ctx, codec); if(out_stream == NULL) { printf("无法创建输出流\n"); exit(1); } if(avcodec_parameters_copy(out_stream->codecpar, codec_par) < 0) { printf("无法复制编解码器参数\n"); exit(1); } if(avio_open(&out_fmt_ctx->pb, "output.mp4", AVIO_FLAG_WRITE) < 0) { printf("无法打开输出文件\n"); exit(1); } if(avformat_write_header(out_fmt_ctx, NULL) < 0) { printf("无法写入输出文件头\n"); exit(1); } ``` 5.创建水印 ```c AVFilterContext *buffersrc_ctx; AVFilterContext *buffersink_ctx; AVFilterGraph *filter_graph; const char *filter_descr = "movie=watermark.png[watermark];[in][watermark]overlay=x=100:y=100[out]"; avfilter_register_all(); AVFilter *buffersrc = avfilter_get_by_name("buffer"); AVFilter *buffersink = avfilter_get_by_name("buffersink"); AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值