一、Google,FF浏览器获取当前js文件的路径 document.currentScript.src //Google,FF 下获取当前js文件的路径//IE10+、Safari和Opera9不支持console.info(document.currentScript.src); 二、比较兼容的获取方式(推荐) //页面解析到当前为止所有的script标签varjs =document.scripts;//js[js.length - 1] 就是当前的...
如路径为 http://localhost:24395/ABC/XX/a.js 结果会得到 http://localhost:24395/ABC/XX/
var js=document.scripts; var jsPath; for(var i=js.length;i>0;i--){ if(js[i-1].src.indexOf("test.js")>-1){ jsPath=js[i-1].src.substring(0,js[i-1].src.lastIndexOf("/")+1); } } alert(jsPath); 这种思路很清晰,根据文件名获取引用的文件的src属性并进行判断截取即可。 但这...
js/java 获取、添加、修改、删除cookie(最全) 2019-12-05 17:57 −一、cookie介绍 1.cookie的本来面目 HTTP协议本身是无状态的。什么是无状态呢,即服务器无法判断用户身份。Cookie实际上是一小段的文本信息(key-value格式)。客户端向服务器发起请求,如果服务器需要记录该用户状态,就使用response向客户端浏览器...
NodeJS获取当前目录和运行文件所在目录 新建文件 /Desktop/demo.js 在/workspace 路径下执行结果 const { resolve } = require('path') // 返回运行文件所在的目录 console.log('__dirname : ' + __dirname) // __dirname : /Desktop // 当前命令所在的目录...
JS获取当前文件所在的文件夹全路径 1 2 varjs = document.scripts; js = js[js.length - 1].src.substring(0, js[js.length - 1].src.lastIndexOf("/") + 1); 如路径为 http://localhost:24395/ABC/XX/a.js 结果会得到 http://localhost:24395/ABC/XX/...
一、Google,FF浏览器获取当前js文件的路径 document.currentScript.src //Google,FF 下获取当前js文件的路径 // IE10+、Safari和Opera9不支持 console.info(document.currentScript.src); 1. 2. 3. 二、比较兼容的获取方式(推荐) //页面解析到当前为止所有的script标签 ...
JS获取当前文件所在的文件夹全路径,varjs=document.scripts;js=js[js.length-1].src.substring(0,js[js.length-1].src.lastIndexOf("/")+1);如路径为 http://localhost:24395/ABC/XX/a.js结果会得到 http://localhost:24
JS获取当前文件所在的文件夹全路径 一、Google,FF浏览器获取当前js文件的路径 document.currentScript.src //Google,FF 下获取当前js文件的路径//IE10+、Safari和Opera9不支持console.info(document.currentScript.src); 二、比较兼容的获取方式(推荐) //页面解析到当前为止所有的script标签varjs =document.scripts;/...