开发者

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

开发者 https://www.devze.com 2023-02-02 03:29 出处:网络
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

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

精彩评论

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

关注公众号