Announcement

Collapse
No announcement yet.

Automatische Iframe Skalierung Safari Browser

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatische Iframe Skalierung Safari Browser

    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
    Attached Files

  • #2
    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";
         }
       }
    }

    Comment


    • #3
      So klappts

      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";
      }
      }
      }

      Comment

      Working...
      X