...

View Full Version : iframe and onclick event



alex57
12-31-2006, 02:50 PM
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

1212jtraceur
12-31-2006, 04:03 PM
You will need to be able to identify the iframes, I recommend an id attribute.

JavaScript:


function refreshIframes()
{
var iframe1 = document.getElementById('id1');
var iframe2 = document.getElementById('id2');

iframe1.src = iframe1.src;
iframe2.src = iframe2.src;
}


XHTML:


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


That should work. If you would like to avoid a javascript: url, use this:



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

Mr J
12-31-2006, 07:13 PM
Here's another option


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum