Results 1 to 3 of 3

Thread: Problem with viewing iFrame on FF and IE

  1. #1
    Join Date
    Jun 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Problem with viewing iFrame on FF and IE

    Hi, I am having a problem with viewing iFrame on FF and IE. It seems that i got the position correct for FF but it doesn't for IE. I have search through the forums but i feel it's the best i can do for now .. as I had used the previously example on this but i had failed. Please advice on my current coding..

    Files being used:
    bug.gif= To re-create the example above but failed.
    miscTopFrame.asp= The header, footer and Nav
    ls.asp= A set of banners on the side
    test.htm = The contents which will appear in iframe.

    Do not mind messy coding. Hope someone really shed some light on this thread so that i can complete this task and share this info to everyone.


    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">

    /***********************************************
    * IFrame SSI script II- ? Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
    * Visit DynamicDrive.com for hundreds of original DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/

    //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
    //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
    var iframeids=["myframe"]

    //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
    var iframehide="yes"

    var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
    var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

    function resizeCaller() {
    var dyniframe=new Array()
    for (i=0; i<iframeids.length; i++){
    if (document.getElementById)
    resizeIframe(iframeids[i])
    //reveal iframe for lower end browsers? (see var above):
    if ((document.all || document.getElementById) && iframehide=="no"){
    var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
    tempobj.style.display="block"
    }
    }
    }

    function resizeIframe(frameid){
    var currentfr=document.getElementById(frameid)
    if (currentfr && !window.opera){
    currentfr.style.display="block"
    if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
    currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
    else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
    currentfr.height = currentfr.Document.body.scrollHeight;
    if (currentfr.addEventListener)
    currentfr.addEventListener("load", readjustIframe, false)
    else if (currentfr.attachEvent){
    currentfr.detachEvent("onload", readjustIframe) // Bug fix line
    currentfr.attachEvent("onload", readjustIframe)
    }
    }
    }

    function readjustIframe(loadevt) {
    var crossevt=(window.event)? event : loadevt
    var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
    if (iframeroot)
    resizeIframe(iframeroot.id);
    }

    function loadintoIframe(iframeid, url){
    if (document.getElementById)
    document.getElementById(iframeid).src=url
    }

    if (window.addEventListener)
    window.addEventListener("load", resizeCaller, false)
    else if (window.attachEvent)
    window.attachEvent("onload", resizeCaller)
    else
    window.onload=resizeCaller

    </script>


    <style type="text/css">
    <!--

    #bug{
    float: left;
    width:18px;
    height:15px;
    margin: 0;
    margin-right: 0;
    padding: 0;
    background-image:url(../Images/bug.gif);
    }

    #content {
    padding: 0;
    margin-left: 160px;
    margin-top:165px;
    width:660px;
    height:358px;
    z-index:1;

    }
    -->
    </style>


    <!--#include file="miscTopFrame.asp" -->


    <table width="185" border="0">
    <tr>

    <th scope="row"><!--#include file="ls.asp" --></th>
    </tr>
    </table>


    <div id = "bug">

    <div id ="content">
    <iframe id="myframe" src="test.htm" scrolling="yes" frameborder="1" width="660" height="358"vspace="50" hspace="50""></iframe>
    </div></div>





  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Just a guess, as I came across something similar recently. Try setting the iframe's margins to 0 (for some odd reason IE's default margins for iframes are not 0, they should be):

    HTML Code:
    <iframe style="margin:0;" id="myframe" src="test.htm" scrolling="yes" frameborder="1" width="660" height="358" vspace="50" hspace="50"></iframe>
    You had two closing quotes on the hspace value, and a missing space in there among the other attributes. The missing space shouldn't matter but might, I have no idea what effect extra quotes might have.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi and thanks alot for you reply. It seems to be the closest it can get but it's not I want.. But I found another workaround by using "Scrollable IFRAME" from DD. However, it's like taking 2 steps forward and 1 step backward kind of day. Even I can able to position the same in IE & FF. I am using swishmax to create a menu to change the contents in the iframe but no success yet. Low Morale anyway, Thanks again.

    This is the code I am refering to. Hope some1 knows how to deal with it while i go and research it.

    Code:
    onSelfEvent (press) {
    	var someURL = "./test.htm";
    	javascript( "frames['DATAMAIN'].location.href = '"+ someURL +"';" );
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •