Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Posts
    216
    Thanks
    9
    Thanked 0 Times in 0 Posts

    iframe and onclick event

    Hello, I have a page which contains two iframes. On this page I have a hyperlink which when clicked I want both iframes to refresh. Is this possible??

    I think the hyperlink should look something like this:

    <a href="javascript:void(0);" onclick="some javasacript">click here</a>

    If someone could fill in the javascript I would be grateful.

    Thanks

  • #2
    Regular Coder
    Join Date
    Oct 2006
    Posts
    206
    Thanks
    1
    Thanked 0 Times in 0 Posts
    You will need to be able to identify the iframes, I recommend an id attribute.

    JavaScript:
    PHP Code:
    function refreshIframes()
    {
        var 
    iframe1 document.getElementById('id1');
        var 
    iframe2 document.getElementById('id2');
        
        
    iframe1.src iframe1.src;
        
    iframe2.src iframe2.src;

    XHTML:
    PHP Code:
    <a href="javascript:void(0);" onclick="refreshIframes();">click here</a
    That should work. If you would like to avoid a javascript: url, use this:

    PHP Code:
    <a href="" onclick="refreshIframes(); return false;">click here</a

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Here's another option

    PHP Code:
    <a href="page1.htm" target="iframename1" onclick="window.frames['iframename2'].location='page2.htm' ; return false">Load</a
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •