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 <blockquotewith "style="visibility: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(someThing) {
var elmt = parent.document.getElementById(someThing).style;
elmt.visibility = elmt.visibility==''? 'hidden' : '';
}
function showHideFull(someThing) {
var elmt = parent.document.getElementById(someThing).style;
elmt.display = elmt.display==''? 'none' : '';
}
function deleteElmt(someThing) {
var elmt = parent.document.getElementById(someThing);
elmt.parentNode.removeChild(elmt);
}
function moveElmt(someThing, tarGet) {
var elmt = parent.document.getElementById(someThing);
tarGet = tarGet=='body'? parent.document.body :
parent.document.getElementById(tarGet)
target.appendChild(elmt);
}
HTML (examples) :
-----------------
<a href="#" onclick="showHide('theBlock')">
hide/show main comment
</a>
<a href="#" onclick="showHideFull('theBlock')">
compress/depress main comment
</a>
<button onclick="moveElmt('theBlock','body')">
move main comment to bottom
</button>
<button onclick="moveElmt('theBlock','here')">
move main comment to div 'here'
</button>
<button onclick="deleteElmt('theBlock')">
delete main comment
</button>
HTML in main window :
=====================
<blockquote id="theBlock"blah ...</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