当前位置:网站首页>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 .
边栏推荐
猜你喜欢

Konva series tutorial 1:what is konva?

App hangs~

Visual display of TEQC quality analysis results using teqcplot

LeetCode 797:所有可能的路径

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

GO语言-自定义error

MCS: continuous random variable chi square distribution

Complete the primary school project in 3 days, and teach you to complete the weather broadcast system hand in hand!

(IntelliJ)插件一 Background Image Plus

Missing essential plugin
随机推荐
View of MySQL introductory learning (III)
AMS:startActivity桌面启动应用
基金业绩评价
MySQL自定义序列数的实现
Image noise reduction denoise AI
Mysql入门学习(二)之子查询+关联
[microservices | Nacos] list of issues related to the Nacos version
GO语言-panic和recover
Onnxoptimizer, onnxsim usage records
MCS: continuous random variable lognormal distribution
关于重放攻击和防御
Win软件 - (Net-Framework)已处理证书链,但是在不受信任提供程序信任的根证书中终止
C语言栈实现
MCS:离散随机变量——Bernoulli分布
Swiftui 2.0 course notes Chapter 4
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.
Sift特征点提取
【Leetcode】最长递增子序列问题及应用
数据库连接异常:create connection error, url: jdbc:mysql://ip/数据库名, errorCode 0, state 08S01问题处理
UnityShader入门精要——Unity中的渲染优化技术(四)