当前位置:网站首页>hash---------history
hash---------history
2022-06-23 05:26:00 【A can't choose】
hash What is it?
hash Property is a readable and writable string , The string is URL Anchor part of , There are usually in the current page href in # Address trigger
hash Changes to the will not cause the page to reload ;
When using a browser to access a web page , If web page URL With medium hash, The page will go to id( or name) And hash The location of elements with the same value ;
adopt window.location.hash attribute Get and set hash value .
When hash The event is triggered when the value changes ,a Labeled href Link for an anchor
When it's clicked : The browser address bar will change as follows
file:///C:/Users/Administrator/Desktop/3.16/05/%E4%BB%A3%E7%A0%81/pra.html
=>
file:///C:/Users/Administrator/Desktop/3.16/05/%E4%BB%A3%E7%A0%81/pra.html#id
hashchange event
(window.onhashchange)
onhashchange The event is currently URL Anchor part of ( With ‘#’ The number is the start ) Trigger when a change occurs .
window.addEventListener('hashchange', function(e) {
console.log(e.oldURL) // Link before change
console.log(e.newURL) // Changed Links
})
window.location.href and window.location.hash and window.location.search
(1)window.location.href What you get is complete URL
url= “www.baidu.com”
such as :window.location.href = ’ www.baidu.com’
(2)window.location.hash You get an anchor link
url= “www.baidu.com#all”
such as :window.location.hash= ’ #all’
(3)window.location.search Get is URL‘?’ The string part after the No
url= “www.baidu.com/?username=aaa&age=10”
such as :window.location.search= ’ ?username=aaa&age=10’
history
History.pushState()
The **history.pushState()** Method to add an entry to the browser's session history stack .
grammar :
pushState(state, unused)
pushState(state, unused, url)
Parameters :
state
The state Object is a JavaScript object , It and by pushState(). Whenever the user navigates to new when , Will trigger state An event , And the properties of this event contain history entries Copy of object .
state An object can be anything that can be serialized The object of . because Firefox take state Object is saved to the user's disk , So that they can be restored after the user restarts the browser , So we are right state The serialized representation of the object imposes 16 MiB Size limit for . If you will state Serialization means that objects larger than this are passed to pushState(), The method will throw an exception . If you need more space than this , We encourage you to use sessionStorage and / or localStorage.
unused
This parameter exists for historical reasons , Don't omit ; Passing an empty string is safe for future changes to the method .
url
New history entry URL Given by this parameter . Please note that , Calling after , The browser will not attempt to load this URL pushState(), But it may try to load later URL, For example, after the user restarts the browser . new URL It doesn't have to be absolute ; If it's relative , Relative to the current URL To analyze . new URL Must be with the current URL Homology ; otherwise ,pushState() An exception will be thrown . If this parameter is not specified , Set it to the current... Of the document URL.
describe :
In a sense , call pushState() Similar to setting window.location = "#foo", Both will create and activate another history entry associated with the current document . however pushState() There are several advantages :
- new URL It can be related to the current URL Any homologous URL. contrary ,
window.locationOnly if you only modify the hash , Settings to keep you in the same document . - If you don't want to change URL, You do not have to change . contrary , Set up
window.location = "#foo";Create a new history entry only if the current hash is not#foo. - You can associate any data with a new history entry . Use a hash based approach , You need to encode all the relevant data into a short string .
frame
frameset
When dividing, you need Get rid of body label
Ideas : First, divide horizontally ( Specifies the height ), Divide vertically ( Specify the width )
Of the link target attribute
| value | describe |
|---|---|
| _blank | Open the linked document in a new window . |
| _self | Default . Open the linked document in the same frame . |
| _parent | Open the linked document in the parent frameset . |
| _top | Open the linked document in the whole window . |
| framename | Open the linked document in the specified frame . |
Be careful : The first four are the system default , meanwhile _blank and _self( Default ) Most used ;
And the fifth one is using ***frameset Frame set *** You can only use it when you need it , And you have to name the framework
And the name cannot be underlined _ start , Otherwise, it will be ignored by the browser .
边栏推荐
猜你喜欢

pkav简单爆破

GO语言-自定义error

Onnxoptimizer, onnxsim usage records

Drag and drop拖放框架

Raspberry pie network remote access

The propeller framework v2.3 releases the highly reusable operator library Phi! Restructure development paradigm to reduce cost and increase efficiency

Spark 离线开发框架设计与实现

How to conduct exploratory data analysis

What do Niu B programmers pay attention to when "creating an index"?

Ams:startactivity desktop launch application
随机推荐
GO语言-自定义error
BGP summary of hcip operation
STP summary
Get bat command results in bat
Qt QWidget嵌套相对位置获取 (qt 画线 嵌套)
C'est dur de trouver un emploi? Ali des trois côtés, heureusement qu'il s'est bien préparé et qu'il a pris un produit.
【opencv450】 图像相减、二值化、阈值分割
应用挂了~
JVM原理之完整的一次GC流程
BGP second test
Fund performance evaluation
导出带水印的PDF
JDBC入门学习(四)之Druid连接池的使用
Spark 离线开发框架设计与实现
Array The from method creates an undefined array of length n
左侧固定,右侧自适应 三种实现办法(Flex,float + BFC ,float-margin-left)
搭建一套 gocd 的环境
MMDeploy快速安装及使用说明
弱者易怒如虎,强者平静如水,真正厉害的人早已戒掉了情绪
A compiler related bug in rtklib2.4.3 B34