开发者

How to load a js function after a new HTML page is loaded?

I wonder if there's a way to do the following:

I have a page on root: "index.html" that has 2 links. Each link has an onclick that directs to "reader/index.html". The reason for the two links is because I want the links to call different functions on "reader/index.html" immediately after the page is loaded. Is there a way to do this?

I know how to use onload to call a function after a page finished loading, but can't figure out how to use onload to call different functions dependi开发者_开发百科ng on an onclick from the previous page. Totally stumped here. Any help is greatly appreciated.


One way to solve this is to pass parameters in the query string:

  • First link: reader/index.html?func=function1
  • Second link: reader/index.html?func=function2

You can read a query string parameter in javascript by using a technique described here.


You need to pass state to reader/index.html.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜