e1n
e1n

Reputation: 1

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 depending on an onclick from the previous page. Totally stumped here. Any help is greatly appreciated.

Upvotes: 0

Views: 167

Answers (2)

kgiannakakis
kgiannakakis

Reputation: 104178

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.

Upvotes: 1

Jim G.
Jim G.

Reputation: 15365

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

Upvotes: 0

Related Questions