导航:首页 > 编程语言 > javascript本地路径

javascript本地路径

发布时间:2021-02-28 05:20:39

A. js取得本地路径的代码

使用javascript来获取当前url网址非常有用。下面以例子讲解:

输入的网址是(没有框架):http://localhost:81/Test/1.htm?Did=123
<br>以下为输出:
<br>
<SCRIPT>

//获取Url传过来的值
function Request(name)
{
new RegExp("(^|&)"+name+"=([^&]*)").exec(window.location.search.substr(1));
return RegExp.$2
}

thisURL = document.URL; // http://localhost:81/Test/1.htm?Did=123
thisHREF = document.location.href; // http://localhost:81/Test/1.htm?Did=123
thisSLoc = self.location.href; // http://localhost:81/Test/1.htm?Did=123
thisDLoc = document.location; // http://localhost:81/Test/1.htm?Did=123

thisTLoc = top.location.href; // http://localhost:81/Test/1.htm?Did=123
thisPLoc = parent.document.location;// http://localhost:81/Test/1.htm?Did=123
thisTHost = top.location.hostname; // localhost
thisHost = location.hostname; // localhost

thisU1 = window.location.protocol; // http:
thisU2 = window.location.host; // localhost:81
thisU3 = window.location.pathname; // /Test/1.htm

document.writeln( thisURL + "<br />");
document.writeln( thisHREF + "<br />");
document.writeln( thisSLoc + "<br />");
document.writeln( thisDLoc + "<br />");

document.writeln( thisTLoc + "<br />");
document.writeln( thisPLoc + "<br />");
document.writeln( thisTHost + "<br />");
document.writeln( thisHost + "<br />");

document.writeln( thisU1 + "<br />");
document.writeln( thisU2 + "<br />");
document.writeln( thisU3 + "<br />");

document.writeln( "Did="+Request("Did") );// Did=123
</SCRIPT>

B. html页面关联本地Js文件,它的路径是什么

<script type="text/javascript" src="/driver/static/js/app/ico/ico/dianhuafuwu.app.js"></script>
SRC里面写路径,相同文件夹下直接写js名。。
不同文件夹的可以写绝对路径(文件夹名/js名.js)和相对路径。 (../表示一层文件夹。有几层就写几个如三层就../../../js名.js)

C. 如何用javascript操作本地文件

js被设计为沙箱式语言,理论上讲是不应该去访问本地文件系统的。
但是网上有访问本地文回件的操作,是通过答ActiveXObject。但是这种写法绑架了浏览器,跟IE绑死,所以建议你如果可以的话,最好不要存类似心思,而是通过其他后台逻辑传送文件内容。

D. HTML中插入javascript本地文件

jquery 也引入一下
并且放在
<script type="text/javascript" src="script.js"></script>的前面

E. javascript 如何分离出本地路径中的文件名

function getFileName()
{
var value=document.all.ff.value;
var last=value.lastIndexOf("\\");
var filename=value.substring(last+1,value.length);
alert(filename);
}
这样合适不?

F. 如何通过JS获取用户本地图片路径

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>get file input full path</title>
<script language='javascript'>
function getFullPath(obj)
{
if(obj)
{
//ie
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
obj.select();
return document.selection.createRange().text;
}
//firefox
else if(window.navigator.userAgent.indexOf("Firefox")>=1)
{
if(obj.files)
{
return obj.files.item(0).getAsDataURL();
}
return obj.value;
}
return obj.value;
}
}
</script>
</head>
<body>
<input type="file" onchange="document.getElementById('img').src=getFullPath(this);" />
<img id="img" />
</body>
</html>

firefox7+请使用return window.URL.createObjectURL(obj.files.item(0));来获取地址

G. js 如何获取当前网页的本地路径

varlcal=location.href;
lcal=substring(0,lcal.lastIndexOf(""));

H. 怎样用js代码引入本地图片的路径

1、本地的图片?HTML只能来连接网站内自的图片,即使在本地,也需要先将图片拷贝到网站内。
2、网页中引用js文件,象你这样如果用到图片路径等时,要注意的是这个路径如果用相对路径表示的话,是网页与图片之间的相对路径,而不是js文件与图片之间的相对路径。如果有多个不同的目录中的网页文件需要引用一个这样的js文件的话,最好的解决办法是用绝对路径。也就是改成:
imgUrl1=("/images/0.gif")
imgtext1="1111"
imgLink1=escape("/XX.html");
imgUrl2=("/images/00.gif");
imgtext2="222"
imgLink2=escape("/XXX.html");

I. 如何获取本地位置 javascript

var getLocation = function (successFunc, errorFunc) { //successFunc获取定位成功回调函数,errorFunc获取定位失败回调
//首先设置默认内城市容
var defCity = {
id: '000001',
name: '北京市',
date: curDateTime()//获取当前时间方法
};
//默认城市
$.cookie('VPIAO_MOBILE_DEFAULTCITY', JSON.stringify(defCity), { expires: 1, path: '/' });
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var lat = position.coords.latitude;

J. javascript 如何判断本地路径文件是否存在并打开

出于安全原因,浏览器不支持此类操作,至少现在不支持。以前IE是可以的,但后来修复了。

阅读全文

与javascript本地路径相关的资料

热点内容
ww.288 浏览:757
人类与兽类的电影 浏览:915
男主是苏辰的都市小说 浏览:655
男男大尺推荐电影 浏览:389
鬼片电影大全很老的鬼片 浏览:409
一个小说男主角叫林枫 浏览:402
低清影视 浏览:76
抢先版电影 浏览:185
虚拟币排线录入数据怎么弄 浏览:208
沈阳商超微信分销系统 浏览:444
6s越狱后程序闪退 浏览:267
怎么打开appx文件 浏览:648
t30x6的梯形螺纹怎么编程 浏览:74
可以看韩国电影的网站 浏览:934
编程机构怎么宣传孩子上课 浏览:782
ug编程在机器上跑太慢怎么解决 浏览:227
手机迅雷国粤双语怎么切换 浏览:59
笔记本数控编程哪个牌子好 浏览:455

友情链接