Q:

How to click on a link and call function on the page that link go to as the same time?

index.html - has menus category1, category2, category3 
product.html - has function changeIframe([category1 | category2 | category3]);

When I click a menu on "index.html" page, a link will bring me to "product.html" page then call function changeIframe(var) immediately. The changeIframe(var) function will compare $var (value of var is followed by the name of menu that I clicked) and then change content in this page. How can I do something like this?

A:

Just an Idea, pass the category as Url Hash.
index.html:
<a href="product.html#category1">Category 1</a>
<a href="product.html#category2">Category 2</a>
<a href="product.html#category3">Category 3</a>

product.html
var category = (location.hash).replace('#','');
changeIframe(category); //call function

If only you do need it using javascript. It'll be more easier if you using server-side script.

