Automatische Iframe Skalierung Safari

M

moloch500

Neues Mitglied
Thread Starter
Dabei seit
25.09.2003
Beiträge
5
Reaktionspunkte
0
Hallo Zusammen,

ich habe folgendes Problem, auf einer HTML Site habe ich per Iframe ein PHP Formular eingebunden.

Code:
<iframe src="/****/****.php?lang=de" width="704" height="545" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" id="pcontent" name="pcontent"></iframe>

Dieser Iframe passt sich per Java Script automatisch an den Iframeinhalt an.

Code:
function autofitIframe() {    

    id = 'pcontent';    

    if (top.document.getElementById(id)){
      
      browser = navigator.appName;
      
      //FireFox

      if (browser == "Netscape"){

        top.document.getElementById(id).style.height = (0 + top.pcontent.document.body.offsetHeight) + "px";

      } else {

        //IE und andere

        top.document.getElementById(id).style.height = (0 + top.pcontent.document.body.scrollHeight) + "px";

      }      
    }

}

Das funktioniert auch soweit ganz gut ausser bei Apples Safari.
Hier wird immer ein grauer Bereich angezeigt (siehe Screenshot im Anhang)
Hat jemand eine Idee, wie man dem Script das noch beibringen kann?

Viele Grüße
Moloch
 

Anhänge

  • iframe.jpg
    iframe.jpg
    16,8 KB · Aufrufe: 68
Mit Safari hab ichs hinbekommen, nur im Opera gehts noch nicht.
Code:
function autofitIframe() {

   id = 'pcontent';

   if (top.document.getElementById(id)){

     browser = navigator.appName;

     //FireFox
     if (browser == "Netscape"){
         top.document.getElementById(id).style.height = (0 + top.pcontent.document.body.offsetHeight) + "px";
         if (navigator.userAgent.indexOf('Safari') != -1) {
            top.document.getElementById(id).style.height = "0px";
            top.document.getElementById(id).style.height = (0 + top.pcontent.document.body.offsetHeight) + "px";
         }
     } else {
       //IE und andere
       top.document.getElementById(id).style.height = (0 + top.pcontent.document.body.scrollHeight) + "px";
     }
   }
}
 
HTML:
<script type="text/javascript">
// <![CDATA[
var ifr, frh, global_if_id = "your_iframe_id";

window.onload = function()
{
    ifr = document.getElementById (global_if_id); 
    frh = window.setInterval ("set_frameheight()", 100);
}

function set_frameheight()
{
    var ifb = window.frames[global_if_id], body = ifb.document.getElementsByTagName ("body")[0];
    
    if (body)
    {
        var hg = body.offsetHeight;
        
        if (body.style.overflow != "hidden")
        
            body.style.overflow = "hidden";

        if (ifr.offsetHeight != hg)
        {
            var newhg = hg;
            
            ifr.style.height = newhg + "px";
            
            frmh = newhg;
        }
    }
}
// ]]>
</script>
 
So funktionierts auch

Code:
function autofitIframe() {

id = 'pcontent';
margin_bottom = 0;

if (top.document.getElementById(id)){

browser = navigator.appName;

if (browser == "Netscape"){ //Fifefox, Safari
top.document.getElementById(id).style.height = (margin_bottom + 
top.pcontent.document.body.offsetHeight) + "px";
if (navigator.userAgent.indexOf('Safari') != -1) {
top.document.getElementById(id).style.height = "0px";
top.document.getElementById(id).style.height = (margin_bottom + 
top.pcontent.document.body.offsetHeight) + "px";
}
} else if (browser == "Opera") { //Opera
top.document.getElementById(id).style.height = "0px";
top.document.getElementById(id).style.height = (margin_bottom + 
document.body.scrollHeight) + "px";
} else {
//IE und andere
top.document.getElementById(id).style.height = (margin_bottom + 
top.pcontent.document.body.scrollHeight) + "px";
}
}
}
 
Zurück
Oben Unten