Otto Wyss a écrit :
Bubu wrote:
>It's possible to hide or show e div from a iFrame page with javascript?
If yes, please can anyone tell me how to do this?
I tried to hide a <blockquotewi th "style="visibil ity:hidden" yet this
just hided the text while the space still was shown as a white area. So
I'm also interested in knowing how to suppress a block.
From/in your frame :
=============== =====
Javascript in head :
--------------------
function showHide(someTh ing) {
var elmt = parent.document .getElementById (someThing).sty le;
elmt.visibility = elmt.visibility ==''? 'hidden' : '';
}
function showHideFull(so meThing) {
var elmt = parent.document .getElementById (someThing).sty le;
elmt.display = elmt.display==' '? 'none' : '';
}
function deleteElmt(some Thing) {
var elmt = parent.document .getElementById (someThing);
elmt.parentNode .removeChild(el mt);
}
function moveElmt(someTh ing, tarGet) {
var elmt = parent.document .getElementById (someThing);
tarGet = tarGet=='body'? parent.document .body :
parent.document .getElementById (tarGet)
target.appendCh ild(elmt);
}
HTML (examples) :
-----------------
<a href="#" onclick="showHi de('theBlock')" >
hide/show main comment
</a>
<a href="#" onclick="showHi deFull('theBloc k')">
compress/depress main comment
</a>
<button onclick="moveEl mt('theBlock',' body')">
move main comment to bottom
</button>
<button onclick="moveEl mt('theBlock',' here')">
move main comment to div 'here'
</button>
<button onclick="delete Elmt('theBlock' )">
delete main comment
</button>
HTML in main window :
=============== ======
<blockquote id="theBlock"bl ah ...</blockquote>
<div id="here"></div>
Notice :
========
Main page and page in iFrame must come from same domain.
----------------
ask to google : cloneNode
also :
createElement parentNode firstChild hasChildNode setAttribute
appendChild ...
--
ASM