简体   繁体   中英

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM