Welcome to Dream.In.Code
Become an Expert!

Join 149,519 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,378 people online right now. Registration is fast and FREE... Join Now!




Iframe help

 
Reply to this topicStart new topic

Iframe help

carlos222006
3 Jul, 2007 - 07:16 AM
Post #1

New D.I.C Head
*

Joined: 3 Jul, 2007
Posts: 2


My Contributions
Is there a way of making a table cell adapt to the contents of an Iframe so you will never experience scrolling in the Iframe.

I am trying to create a page where the table will change size and the Iframe will change size so the contents of the Iframe will always fit on the page or in the cell. Where no scrolling is necessacery.

I already got a code but seems that code only works on IE not Firefox

This part of the code is not made by me

Goes in the header of the page
CODE
<script type="text/javascript">
var iframeids=["Main_page"]
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>


Goes where you want the iframe
CODE
<iframe id="Main_page" src="news.htm" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none">
If you can see this, your browser doesn't understand and use IFRAME's. However, we'll still <A HREF="news.htm">link</A> you to the file.</iframe>


It works great on IE but no Firefox

Any help


User is offlineProfile CardPM
+Quote Post

dean.h
RE: Iframe Help
4 Jul, 2007 - 03:30 AM
Post #2

New D.I.C Head
*

Joined: 4 Mar, 2007
Posts: 12


My Contributions
Hi carlos.

I myself used to use iframes and in my experience the scrolling will always occur in firefox.

The best advice I can give you is to do what I did, and abandon using the iframes, as what you want to do can easily be achieved with tableless CSS site design. If you are not familiar with it, there are lots of books out there, or you can just browse the web, you'll find lots to help you out.

If you have any questions dont hesitate to ask.

Dean
User is offlineProfile CardPM
+Quote Post

carlos222006
RE: Iframe Help
4 Jul, 2007 - 09:17 AM
Post #3

New D.I.C Head
*

Joined: 3 Jul, 2007
Posts: 2


My Contributions
Does it do the same thing as iframe
User is offlineProfile CardPM
+Quote Post

dean.h
RE: Iframe Help
5 Jul, 2007 - 12:03 PM
Post #4

New D.I.C Head
*

Joined: 4 Mar, 2007
Posts: 12


My Contributions
It will do the same as an Iframe, and you wont get cross browser problems if you code in css (saving you time having to hack for IE)
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:11PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month