Search code examples
javascriptiframeloadonclicksidebar

Onclick to iframe? Filling anchor on same mouse click? Loading separate URL in to sidebar without any extra input?


I am attempting to have a link load an article from my domain in to an iframe. I understand that it is usually easy to link using:

<a href="#" onClick="window.open('http://www.google.com');return false">Google</a>

But when it comes to Iframes I am having difficulty formatting the code correctly so that it will display inside the iframe.

This leads in to my next question. If this is easily remedied then is it possible to also execute code that will fill in the URL of an anchor in the same mouse click.

Finally, in that same mouseclick would you be able to execute code similar to:

$('#abc').click(function() { $('#xyz').load('content.html'); });

In order to populate a sidebar with information from a second link?

Thank you for taking the time to read over this. I am sorry if it is truly elementary, but this is my first bona fide webpage, and my limited knowledge is really delaying the execution of my ideas.

Special thanks to wdm for allowing me to progress to this stage of questioning by answering my earlier concerns.


Solution

  • To target your iframe, change to:

    <a href="http://www.google.com" target="your_frame_name">Google</a>
    

    for the 2nd part, the above thing can be reused instead of using jQuery.