js 获取当前页面路径 & 页面刷新几种方法

设置或获取对象指定的“文件名”或路径。

<script> alert(window.location.pathname) </script>

设置或获取整个 URL 为字符串。

<script> alert(window.location.href); </script>

设置或获取与 URL 关联的端口号码。

<script> alert(window.location.port) </script>

设置或获取 URL 的协议部分。

<script> alert(window.location.protocol) </script>

设置或获取 href 属性中在井号“#”后面的分段。

<script> alert(window.location.hash) </script>

设置或获取 location 或 URL 的 hostname 和 port 号码。

<script> alert(window.location.host) </script>

设置或获取 href 属性中跟在问号后面的部分。

<script> alert(window.location.search) </script>

网页刷新推荐-JS

<input type=button value=刷新 onclick="history.go(0)">

<input type=button value=刷新 onclick="location.reload()">

<input type=button value=刷新 onclick="location=location">

<input type=button value=刷新 onclick="location.assign(location)">

<input type=button value=刷新 onclick="document.execCommand(‘Refresh‘)">

<input type=button value=刷新 onclick="window.navigate(location)">

<input type=button value=刷新 onclick="location.replace(location)">

<input type=button value=刷新 onclick="document.URL=location.href">

【转载】http://blog.sina.com.cn/s/blog_6b36f2fe0100lqzs.html

时间: 2024-08-26 14:01:36

js 获取当前页面路径 & 页面刷新几种方法的相关文章

JS获取网页中HTML元素的几种方法分析

getElementById getElementsByName getElementsByTagName 大概介绍 getElementById ,getElementsByName ,getElementsByTagName ###adv### 后两个是得到集合,byid只是得到单个对象 getElementById 的用法 举个例子: <a id="link1" name="link1" href=http://homepage.yesky.com>

Jsp页面跳转和js控制页面跳转的几种方法

Jsp 页面跳转的几种方法 1. RequestDispatcher.forward() 在服务器端起作用,当使用forward()时,Servlet engine传递HTTP请求从当前的Servlet或者是JSP到另外的一个Servlet.JSP 或普通HTML文件,也即你的form提交至a.jsp,在a.jsp用到了forward()重定向至b.jsp,此时form提交的所有信息在 b.jsp都可以获得,参数自动传递. 但forward()无法重定向至有frame的jsp文件,可以重定向至有

java ,js获取web工程路径

一.java获取web工程路径 1),在servlet可以用一下方法取得: request.getRealPath(“/”) 例如:filepach = request.getRealPath(“/”) ”//upload//”; 2),不从jsp,或servlet中获取,只从普通java类中获取: String path = getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); SAXReader()

js获取项目根路径

1 //js获取项目根路径,如: http://localhost:8083/uimcardprj 2 function getRootPath(){ 3 //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp 4 var curWwwPath=window.document.location.href; 5 //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp 6 var pathName=wind

java 或者 js 获取项目访问路径(域名)

/** * 获得站点url * @return */ public String getWebUrl(){ String url = getRequest().getScheme() + "://" + getRequest().getServerName(); if(getRequest().getServerPort()!=80){ url+= ":" + getRequest().getServerPort(); } url+=getRequest().get

vue-cli在打包后js获取的图片路径错误问题时候

在用npm run build 打包的时候,正常img标签中的src图片路径和css中的图片路径是可以正常识别的, 但是在打包js获取的图片路径时,打包后无法找到图片,原因是 js动态生成的路径无法被url-loader解析到,如果你去build,会发现图片甚至不会打包输出到dist目录(webpack是按需打包的). 如果你是vue-cli初始化的项目,解决的办法:第一步,把图片放到src同级的static目录(build/build.js文件中有一段代码是把static目录拷贝到dist/s

js返回上一页并刷新的多种方法

js返回上一页并刷新的几种方法.参考链接:http://www.jbxue.com/article/11230.html <a href="javascript:history.go(-1)">返回上一页</a><a href="javascript:location.reload()">刷新当前页面</a><a href="javascript:" onclick="history

HTML 页面跳转的五种方法

H方法TML 页面跳转的五种方法 下面列了五个例子来详细说明,这几个例子的主要功能是:在5秒后,自动跳转到同目录下的hello.html(根据自己需要自行修改)文件.1) html的实现 <head><!-- 以下方式只是刷新不跳转到其他页面 --><meta http-equiv="refresh" content="10"><!-- 以下方式定时转到其他页面 --><meta http-equiv="

HTML中button标签点击实现页面跳转的三种方法

方法1:使用onclick事件12<input type="button" value="按钮"onclick="javascrtpt:window.location.href='http://www.9252.com/'" /> 或者直接使用button标签1<button onclick="window.location.href = 'https://www.9252.com/'">儿童</

获取母版页的相关内容有两种方法 --全了

获取母版页的相关内容有两种方法 1 通过findcontrol找控件ID需要在此事件中~因为Page_load中时是先内容页加载然后才是母版页加载    protected void Page_LoadComplete(object sender, EventArgs e)    {        Label2.Text = "现在时间是" + (Master.FindControl("Label1") as Label).Text;        if (Requ