crazyvi
crazyvi

Reputation: 57

Display iframe content according to link

I have an iframe in my page and I want to display the content according to the link (anchor tag) selected. I would like to achieve this using javascript.

My doubts are:

  1. How to retrieve which anchor tag is selected.
  2. If I call javascript from onclick() function in anchor tag and don't add a href attribute, then the anchor tag (link) loses it hyperlink property. So how can I add a href attribute in this case

Upvotes: 0

Views: 1003

Answers (1)

Colin
Colin

Reputation: 2824

Give your iframe a name attribute, IE:

<iframe src="startpage.html" name="content"></iframe>

Then when you create your links, set the target attribute to the same value. IE:

<a href="nextpage.html" target="content">Next Page</a>

Upvotes: 1

Related Questions