首页 > 编程知识 正文

历史股价查询网站,历史数据股票工具

时间:2023-05-05 05:40:54 阅读:54026 作者:3663

股票行情历史数据api

国际教育

介绍

访问历史记录API

访问历史记录API

导航历史

浏览历史

Add an entry to the history

向历史记录中添加条目

修改历史入口

修改历史记录

访问权限

访问当前历史记录输入状态

The onpopstate event

onpopstate事件

介绍(Introduction ) thehistoryapiletsyou http://www.Sina.com /,http://www.Sina.com/and http://www.Sina.com /。

History API提供interact with the browser historytrigger the browser navigation methodschange the address bar content

it’sespeciallyusefulincombinationwithmodernsinglepageapplications,onwhichyounevermakeaserver-siderequestfornewpages,buewpages

与现代单页面APP应用程序结合使用特别有用。 此APP应用程序不会在服务器端请求新页面。 页面总是一样的。 只是内部内容发生了变化。

a http://www.Sina.com/runninginthebrowserthatdoesnotinteractwiththehistoryapi,eitherexplicitlyorattheframeworklevel,isggithed

在浏览器中运行的可以与浏览器历史记录交互不与History API交互,无论是显式还是框架级。 由于3358www.Sina.com/,对用户来说是很糟糕的体验。

Also,when navigating the app,触发浏览器导航方法

另外,浏览APP时,请访问更改地址栏内容

andalso http://www.Sina.com/: reloading the page,since there is no deep linking,isgoingtomakethebrowsershowadifferentpage

modern JavaScript application:由于没有深链接,重新加载页面时浏览器将显示不同的页面

thehistoryapiwasintroducedinhtml5andisnowsupportedbyallmodernbrowsers.iesupportsitsinceversion 10,andifyouneedtosupportie9aaa

历史API在HTML5中引入,目前所有现代浏览器都支持。 IE从版本10开始受支持。 如果需要支持IE9之前的版本,请使用History.js库。

历史API (访问历史记录API ) thehistoryapiisavailableonthewindowobject,soyoucancallitlikethis 3360 window.historyorhistory

历史API是可用的窗口对象,因此可以这样调用。 window.history或history

,因为window是全局对象。

浏览历史 (Navigate the history)

Let’s start with the simplest thing you can do with the History API.

让我们从您可以使用History API进行的最简单的操作开始。

Go back to the previous page:

返回上一个页面:

history.back()

this goes to the previous entry in the session history. You can forward to the next page using

这将转到会话历史记录中的上一个条目。 您可以使用转到下一页

history.forward()

This is exactly just like using the browser back and forward buttons.

这就像使用浏览器的后退和前进按钮一样。

go() lets you navigate back or forward multiple levels deep. For example

go()可让您深入浏览或前进多个级别。 例如

history.go(-1) //equivalent to history.back()history.go(-2) //equivalent to calling history.back() twicehistory.go(1) //equivalent to history.forward()history.go(3) //equivalent to calling history.forward() 3 times

To know how many entries there are in the history, you can call

要知道历史记录中有多少个条目,您可以致电

history.length 在历史记录中添加一个条目 (Add an entry to the history)

Using pushState() you can create a new history entry programmatically. You pass 3 parameters.

使用pushState()可以以编程方式创建新的历史记录条目。 您传递3个参数。

The first is an object which can contain anything (there is a size limit however, and the object needs to be serializable).

第一个是可以包含任何内容的对象(但是存在大小限制,并且该对象需要可序列化)。

The second parameter is currently unused by major browsers, so you generally pass an empty string.

当前主流浏览器未使用第二个参数,因此通常传递一个空字符串。

The third parameter is a URL associated to the new state. Note that the URL needs to belong to the same origin domain of the current URL.

第三个参数是与新状态关联的URL。 请注意,该URL必须属于当前URL的同一原始域。

const state = { name: 'Flavio' }history.pushState(state, '', '/user')

Calling this won’t change the content of the page, and does not cause any browser action like changing window.location would.

调用此操作不会更改页面的内容,并且不会引起任何浏览器操作,如更改window.location那样。

修改历史记录 (Modify history entries)

While pushState() lets you add a new state to the history, replaceState() allows you to edit the current history state.

虽然pushState()允许您向历史记录添加新状态,但是replaceState()允许您编辑当前历史记录状态。

history.pushState({}, '', '/posts')const state = { post: 'first' }history.pushState(state, '', '/post/first')const state = { post: 'second' }history.replaceState(state, '', '/post/second')

If you now call

如果您现在打电话

history.back()

the browser goes straight to /posts, since /post/first was replaced by /post/second

浏览器直接转到/posts ,因为/post/first被/post/second 替换

访问当前历史记录输入状态 (Access the current history entry state)

Accessing the property

进入物业

history.state

returns the current state object (the first parameter passed to pushState or replaceState).

返回当前状态对象(传递给pushState或replaceState的第一个参数)。

onpopstate事件 (The onpopstate event)

This event is called on window every time the active history state changes, with the current state as the callback parameter:

每次活动历史记录状态更改时,都会在window上调用此事件,并将当前状态作为回调参数:

window.onpopstate = event => { console.log(event.state)}

will log the new state object (the first parameter passed to pushState or replaceState) every time you call history.back(), history.forward() or history.go().

每次调用history.back() , history.forward()或history.go() ,都会记录新的状态对象(传递给pushState或replaceState的第一个参数history.go() 。

翻译自: https://flaviocopes.com/history-api/

股票历史行情数据api

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。

  • 相关阅读