htmlanchorhreftargetframeset

HTML How can I make one anchor change multiple framesets to different things


How can I make one anchor change multiple framesets to different things

<a href='link1' target='01'>1</a>
<a href='link2' target='02'>2</a>
<a href='link3' target='03'>3</a>

How to do this with only 1 anchor?


Solution

  • Changing these with JS is extremely simple:

    function changeTarget(element) {
        element.setAttribute("target", "02"); //Or whatever. Just use the .setAttribute method to change the attributes you want.
    }
    

    Here's the HTML code:

    <!--You'll have to add something to your link though-->
    <a href="link1" target="01" onclick="changeTarget(this)">1</a>
    

    As always when working with JS, make sure your files are linked correctly, using the syntax below:

    <script src="file.js"></script>
    

    Just ask if you need clarification of anything!