2009年6月1日 星期一

iframe javascript interaction

refresh an iframe by JavaScript from the parent page

var f = document.getElementById('iframe1');
f.contentWindow.location.reload(true);


reload function parameter:
false - Reloads the page from the browser cache. Default.
true - Reloads the page from the server.

solution from Re: Refresh iframe by marss


Calling Javascript between IFRAME and Parent frame

1. written in parent, called from within iframe:
//for firefox OK! but not all browser
parent.function_name();


2. witten in iframe, called from within the parent:
top.frames[name].function_name();

(Added @ 2009-06-01)The following is read from Accessing a javascript function in a nested iframe in IE, tested OK in IE, Firefox and Chrome
document.getElementsByTagName('iframe')[0].function_name();


NOTE: javascript interaction between 2 windows
Read Call parent window's javascript function from child window OR passing data from child window to parent window in javascript by chiragrdarji

//use element object directly
parent.document.getElementById(id)

http://topic.csdn.net/u/20080922/13/ab72e9b1-f42a-411e-a742-a7c75e592965.html

沒有留言:

Powered By Blogger