当前位置:网站首页>Dynamically determine file types through links
Dynamically determine file types through links
2022-07-26 10:18:00 【CS beat you】
1, Determine the type of link :
// The judgment is the picture 、 video 、ex、word One of them
function checkform(f_content){
console.log(" link :"+f_content);
var fileext=f_content.substring(f_content.lastIndexOf("."),f_content.lastIndexOf("?"));
fileType=fileext.toLowerCase();
console.log(fileType);
if(
fileType == ".jpg" || fileType == ".JPG" || fileType == "image/jpeg" ||
fileType == ".png" || fileType == ".PNG" || fileType == "image/png" ||
fileType == ".gif" || fileType == ".GIF" || fileType == "image/gif"
){
return 0;
}
if (fileType=='.mp4'||fileType=='.m2v'||fileType=='.mkv'){
return 1;
}
if (fileType=='.xls'||fileType=='.xlsx'){
return 2;
}
if (fileType=='.doc'||fileType=='.docx'){
return 3;
}
return -1;
}2, The echo : If it's pictures and vidoe Just show , Otherwise, directly through a Click the note to download
// Incoming link judgment
var type = checkform(document);
console.log("-===============:"+type);
if(type==0){
dom += '<img style="width: 100%;margin-bottom: 10px" src="'+document+'">'
}else if(type==1){
dom += '<video th:src="'+document+'" controls\n'
+ ' style="width: 100%;margin-bottom: 10px"></video>'
}else if(type==2){
//dom += '<iframe id="excelIframe" src=https://view.officeapps.live.com/op/view.aspx?src="'+document+'" width=\'100%\' height=\'100%\' frameborder=\'1\'></iframe>'
var image = 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1575615615720&di=94fe53f0421941f41cf9d21527e5f093&imgtype=0&src=http%3A%2F%2Fwww.szrcpx.com%2Fuploads%2F181203%2F1-1Q203161202104.jpg';
dom+='<img style="width: 40px;margin-bottom: 10px" src="'+image+'"><a href="'+document+'" \n'
+ '\t\t \t\tdownload="test.png"> Click to download </a>\n';
}else if(type==3){
var image = 'http://img3.imgtn.bdimg.com/it/u=3838238180,3232741685&fm=26&gp=0.jpg';
dom+='<img style="width: 40px;margin-bottom: 10px" src="'+image+'"><a href="'+document+'" \n'
+ '\t\t \t\tdownload="test.png"> Click to download </a>\n';
}else{
// Can't find
}According to the effect :

边栏推荐
- 30 minutes to thoroughly understand the synchronized lock upgrade process
- Formwork (III)
- Flask framework beginner-03-template
- Some descriptions of DS V2 push down in spark
- SQL优化的魅力!从 30248s 到 0.001s
- Introduction to latex, EPS picture bounding box
- About automatic operation on Web pages
- PHP one-time request lifecycle
- 面试第一家公司的面试题及答案(一)
- The problem of four columns of Hanoi Tower
猜你喜欢

Wechat applet learning notes 1

What will the new Fuzhou Xiamen railway bring to Fujian coastal areas?

Beginner of flask framework-04-flask blueprint and code separation

Cause: couldn‘t make a guess for 解决方法

Learning about tensorflow (II)

分布式网络通信框架:本地服务怎么发布成RPC服务

PLC概述

【Halcon视觉】图像滤波

Data communication foundation telnet remote management equipment

【Halcon视觉】图像滤波
随机推荐
【有奖提问】向图灵奖得主、贝叶斯网络之父 Judea Pearl 提问啦
【Halcon视觉】图像滤波
Common errors when starting projects in uniapp ---appid
Vectortilelayer replacement style
What will the new Fuzhou Xiamen railway bring to Fujian coastal areas?
Vs Code configures go locale and successfully installs go related plug-ins in vscode problem: Tools failed to install
INSTALL_ FAILED_ SHARED_ USER_ Incompatible error resolution
About automatic operation on Web pages
Uniapp error 7 < Map >: marker ID should be a number
Getting started with SQL - combined tables
Interview shock 68: why does TCP need three handshakes?
30分钟彻底弄懂 synchronized 锁升级过程
The practice of OpenCV -- bank card number recognition
Data communication foundation - layer 2 switching principle
面试突击68:为什么 TCP 需要 3 次握手?
Nodejs service background execution (forever)
In Net 6.0
Self encapsulated database dbutils universal template
SQL Server 2008 server engine failed to start?
Under win10 64 bit, matlab fails to configure notebook