前端获取当前域名,url等信息

news/2024/7/10 22:55:09 标签: jquery

1,设置或获取对象指定的文件名或路径: window.location.pathname

2,设置或获取整个 URL 为字符串: window.location.href

3,设置或获取与 URL 关联的端口号码: window.location.port

4,设置或获取 URL 的协议部分: window.location.protocol

5,设置或获取 href 属性中在井号“#”后面的分段: window.location.hash

6,设置或获取 location 或 URL 的 hostname 和 port 号码: window.location.host

7,设置或获取 href 属性中跟在问号后面的部分: window.location.search

8,获取变量的值(截取等号后面的部分)

			var url = window.location.search;
			
			// alert(url.length);
			
			// alert(url.lastIndexOf('='));
			
			var loc = url.substring(url.lastIndexOf('=')+1, url.length);

9,用来得到当前网页的域名

		var domain = document.domain;
		
		    url里的参数
		    function GetQueryString(name)
		    {
		    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		    var r = window.location.search.substr(1).match(reg);
		    if(r!=null)return unescape(r[2]); return null;
		    }
		
		// 调用方法
		alert(GetQueryString("参数名1"));

http://www.niftyadmin.cn/n/1522463.html

相关文章

监听文件夹,如果有新文件添加,则将该文件直接上传服务器

我的监听是在启动类添加 MapperScan ServletComponentScan ComponentScan SpringBootApplication public class AbcApplication { public static void main(String[] args) { SpringApplication.run(AbcApplication.class, args); ListeneFolder listennew ListeneFolder(); //…

重置form表单所有内容

$(’#form表单id’)[0].reset();

循环删除List集合中的实体类元素

一、首先基本的for循环,但也是最容易出错的地方 for(int i0;i<list.size();i){ if(list.get(i).getName().equals(“aaa”)){ list.remove(i); } } remove()方法删除元素后会立刻更新List的size&#xff0c;因此index也发生了变化&#xff0c;会导致漏掉某些元素。解决办法1…

mysql 导入大SQL文件 如何设置

因为mysql在默认清空下,当你执行SQL文件的时候,事务时自动提交的,也就是说insert一次就要执行提交一次,这样会导致导入速度很慢,所以在导入SQL大文件时,设置一下mysql将自动提交关闭,就能大大缩减时间1、可以从黑窗口进入mysql mysql -u root -p 2、输入数据库密码 3、可以创建…

判断在select下拉框中是否存在某个指定值的option元素

aaa是select的的id 第一种: var res $(’#aaa’).find(“option[value”动物"]"); if (res.length > 0) { alert(有) }else{ alert(没有) } 第二种: var opts document.getElementById(‘aaa’).options; for(var i0, nopts.length; i<n; i){ if(opts[i].val…

本地maven运行命令 安装已下载好的jar 到本地

打开本地cmd窗口 aaa bbb 1.1.3 mvn install:install-file -Dfilee:/ccc.jar(jar包的位置) -DgroupIdaaa(上面的groupId) -DartifactIdbbb(上面的artifactId) -Dversion1.1.3(上面的version) -Dpackagingjar

图片转换png格式

srcpath: e:bbb.tif (图片路径) targetPath: e:aaa.png(转换后的图片路径) try { this.tif2Jpg(srcpath, targetPath); } catch (IOException e1) { e1.printStackTrace(); System.out.println(“tif转换jpg失败&#xff01;”); } public void tif2Jpg(String srcFile, Strin…

本地生成keystore是报错拒绝访问

在cmd下生成android apk 签名时&#xff0c;输入命令&#xff1a;keytool -genkey -alias MyAndroidKey.keystore -keyalg RSA -validity 20000 -keystore MyAndroidKey.keystore&#xff0c;到最后提示keytool 错误: java.io.FileNotFoundException: MyAndroidKey.keystore (拒…