Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JavaScript] Obsługa javascript w operze
Forum PHP.pl > Forum > Przedszkole
nikestylex7
Mam problem ze skryptem powiększającym okienko iframe czyli iframe height. Działa pod firefoxa chrome i IE lecz pod opere nie. Jak zrobić żeby działało ?

Oto js :

<script type="text/javascript">
function setIframeHeight(iframeName) {
var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
if (iframeEl) {
iframeEl.style.height = "auto";
// need to add to height to be sure it will all show
var h = alertSize(iframeName);
iframeEl.style.height =h + "px";
}
}

function alertSize(frameId) {
var myHeight = 0;
frame = document.getElementById(frameId);
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0;
myHeight=frame.contentDocument.body.offsetHeight+FFextraHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'

innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
myHeight= innerDoc.body.scrollHeight + 10;
//myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myHeight = document.body.clientHeight;
}
//window.alert( 'Height = ' + myHeight );
return myHeight;
}
</script>
lepmajster
Zrob to przy uzyciu getAttrubute i setAttribute, a powinno dzialac.
nikestylex7
Możesz mi jakoś objaśnić jak to zrobić bo na javascript się nie znam sad.gif niestety.
lepmajster
  1. <script type="text/javascript">
  2. function add_width( id ) {
  3. var element = document.getElementById( id );
  4. var element_width = element.getAttribute( 'width' );
  5. element.setAttribute( 'width', Number( element_width ) + Number( 100 ) );
  6. }
  7.  
  8. <iframe id="ramka" width="300" height="100" src="http://google.pl"></iframe><br>
  9. <button onclick="add_width('ramka');">ADD</button>


Na drugi raz poczytaj jakies manuale, bo to nic trudnego.

EDIT: Ja zrobilem powiekszanie Width, bo wydawalo mi sie ze o to ci chodzi, ale zmienic ten kod na height nie powinno byc juz problemem dla ciebie...
nikestylex7
No tak ale mi chodzi o height. Wraz z powiększoną treścią powiększyło mi okienko i frame. Odwiedź moją stronę Chodzi o shoutboxa.
lepmajster
Cytat(nikestylex7 @ 1.12.2010, 14:43:49 ) *
No tak ale mi chodzi o height. Wraz z powiększoną treścią powiększyło mi okienko i frame. Odwiedź moją stronę Chodzi o shoutboxa.

Skoro nie potrfisz zamienic width na height, to o czym my rozmawiamy?
nikestylex7
Rozumiem że chcesz mi pomóc lecz chodzi mi o to żeby to było zautomatyzowane a nie klikając w button
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.