HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
iframe not laoding properly
Goto page 1, 2  Next
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Frame
View previous topic :: View next topic  
Author Message
vedica



Joined: 23 Apr 2007
Posts: 11
Location: Noida, India

PostPosted: Mon Apr 23, 2007 10:25 pm     iframe not laoding properly Reply with quote

I am in the middle of creating a website and have used different iframes in two of the pages.
I have also used a javascript to fix the png transparency in IE (<7):
http://www.freewebs.com/juhi21/pngfix.js , with the following code in the head section of each page:
Code:
<head>
<!--[if lt IE 7.]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->
</head>

Everything goes fine in Firefox all the time, but in IE (6) the iframe starts to load but then goes blank when the loading is done. if i remove the code from the head section of the pages(not the iframes), it works fine, only ofcourse without alpha transparency.
Page with png-fix code included: http://www.freewebs.com/juhi21/guestbook.htm
(iframe source: http://www.freewebs.com/juhi21/guestbook_frame.html)
page without png fix code included:
http://www.freewebs.com/juhi21/news.htm (iframe source: http://www.freewebs.com/juhi21/news_frame.htm)

How can I make both the png-fix and the iframes work at the same time? Kindly point out the source of the problem and the solution, if any. I am a complete newbie, so it might be something really stupid as well.[/code]
graphicsgod



Joined: 06 Feb 2007
Posts: 65

PostPosted: Wed Apr 25, 2007 11:41 am     Reply with quote

Try this instead.

Put this on the pages you want to fix the gifs or pngs for older browsers between the header tags.

Code:

<style type="text/css">
img {
   behavior: url("fixmypngs.htc");
}
</style>


And create a text file and put this text in there and save. Then rename the text file to "fixmypngs.htc".

Code:

<public:component lightWeight="true">
<public:attach event="onpropertychange" onevent="propertyChanged()" />
<public:attach event="onbeforeprint" onevent="beforePrint()" for="window"/>
<public:attach event="onafterprint" onevent="afterPrint()" for="window"/>
<script>

var supported = /MSIE ((5\.5)|[6789])/.test(navigator.userAgent) &&
            navigator.platform == "Win32";

var realSrc;
var blankSrc = "images/blank.gif";
var isPrinting = false;

if (supported) fixImage();

function propertyChanged() {
   if (!supported || isPrinting) return;

   var pName = event.propertyName;
   if (pName != "src") return;
   // if not set to blank
   if (!new RegExp(blankSrc).test(src))
      fixImage();
};

function fixImage() {
   // get src
   var src = element.src;

   // check for real change
   if (src == realSrc && /\.png$/i.test(src)) {
      element.src = blankSrc;
      return;
   }

   if ( ! new RegExp(blankSrc).test(src)) {
      // backup old src
      realSrc = src;
   }

   // test for png
   if (/\.png$/i.test(realSrc)) {
      // set blank image
      element.src = blankSrc;
      // set filter
      element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft." +
               "AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
   }
   else {
      // remove filter
      element.runtimeStyle.filter = "";
   }
}

function beforePrint() {
   isPrinting = true;
   element.src = realSrc;
   element.runtimeStyle.filter = "";
   realSrc = null;
}

function afterPrint() {
   isPrinting = false;
   fixImage();
}

</script>
</public:component>


Now test it out! It should work, and allow your iframes to work as well.


Also if you want an iframe code that auto exopands and looks like it's part of the page... Try this.

This goes in the header area.

Code:

<script type="text/javascript">
var iframeids=["Name_of_iFrame_here"]
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])
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>

If you want more iframes to work with the same code, just add a comma between each iframe name.

Example:
Code:

var iframeids=["iFrame_One","iFrame_Two","iFrame_Three"]


And this goes in the body section.

Code:

<iframe id="Name_of_iFrame_here" src="webpage.html" 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="webpage.html">link</A> you to the file.</iframe>


Enjoy!

Rob
vedica



Joined: 23 Apr 2007
Posts: 11
Location: Noida, India

PostPosted: Sun Apr 29, 2007 1:18 am     Reply with quote

thanx a lot for the help.. but it still doesnt seem 2 work in ie 6. as the links i mentioned earlier are dead now..here're the new ones:
page with earlier code: http://www.freewebs.com/juhi21/
page with your code: http://www.freewebs.com/juhi21/index%5Fdummy%5Fframed%5Ffixed.htm
graphicsgod



Joined: 06 Feb 2007
Posts: 65

PostPosted: Tue May 01, 2007 10:43 am     Reply with quote

Hmm intresting...

Did you create a text file, insert the code, save it as "fixmypngs.htc", and upload it to where the page is at?

I know it works, since I've been using it for a few years.

Heres a quick website I made a few months ago for a friend.

http://www.idtagem.com

Theres two PNGs and the rest are GIFs with transparencies. I've tested it on all browsers and only I.E.4&3 the code won't work on.

Rob
graphicsgod



Joined: 06 Feb 2007
Posts: 65

PostPosted: Tue May 01, 2007 11:17 am     Reply with quote

BTW... Very nice website and layout!! Just got done looking at it. Did you use any programs or code it the "fun way" Wink?

Rob
Keikura



Joined: 24 Mar 2007
Posts: 167
Location: U.K.

PostPosted: Tue May 01, 2007 11:20 am     Reply with quote

Might wanna sort out that repeated background.

The bg your using is less than the width of my browser window so it repeats horizontally.
graphicsgod



Joined: 06 Feb 2007
Posts: 65

PostPosted: Tue May 01, 2007 11:35 am     Reply with quote

LOL, just noticed that!! Yeah that can be a big issue for those with browsers full screen or larger screens!

I would put that middle image in a table or something and separate it from the pink background..

Rob
vedica



Joined: 23 Apr 2007
Posts: 11
Location: Noida, India

PostPosted: Wed May 02, 2007 4:36 am     Reply with quote

Hey,
I just now tried to use ur code all over again, 2 c if i mite hv made sum mistake....it sure looks different from what it did when i used it last time, but there are those red crosses over the images, and the iframe transparencies are still not working...link: http://www.freewebs.com/juhi21/index%5Fdummy%5Fframed%5Ffixed.htm

yeah, ur website looks pretty cool!...all the images were looking fine in ie, guess it shud work with me too. Sad

Quote:
BTW... Very nice website and layout!! Just got done looking at it. Did you use any programs or code it the "fun way" Wink?

thanx! nah i m afraid i dont no enuf html 2 do it the 'fun' way, i used dreamweaver. Smile
graphicsgod



Joined: 06 Feb 2007
Posts: 65

PostPosted: Wed May 02, 2007 4:31 pm     Reply with quote

Ok perfect!!!!!!!!!!

Now were on the right track. Now for the part I left out Wink. Don't worry, I did that on purpose!

Your missing a blank GIF image that the HTC file is trying to find Wink. What you need to do is create a blank 1 pixel by 1 pixel GIF image and call it "blank.gif". Techincally you can call it anything you want, you will just have to change the name in the HTC file. You'll need to change that info any way since I have the blank.gif in a "images" directory. You'll need to change this to point it to where you will have that file stored on your server. Or you can create an "images" directory and put it there, your call!

And if you don't feel like making the image, or don't have the tools.

Click here for the file.

http://www.idtagem.com/images/blank.gif
(to see the "dot", just hit control-A and it will select all of the page. You should see a little dot appear in the top left side of the browser. Now just right click on it and choose "Save As". You know the rest!)

Enjoy and peace!

Rob
graphicsgod



Joined: 06 Feb 2007
Posts: 65

PostPosted: Wed May 02, 2007 4:39 pm     Reply with quote

vedica wrote:
yeah, ur website looks pretty cool!...all the images were looking fine in ie, guess it shud work with me too. Sad.


Thanks. That site could have been better, but I was going by a quick sketch on a bar napkin and was only given a weekend to do it in since she wanted to sell they're stuff ASAP Sad. And since I code using only notepad, most of that time was for coding, the images were slapped in at the last minute.

My favorite recent websites was for a radio station and a Sirius radio program. Unfortunately I can't seem to find the links right now, I guess I could post an image off my HD... or something.

Rob
graphicsgod



Joined: 06 Feb 2007
Posts: 65

PostPosted: Wed May 02, 2007 5:12 pm     Reply with quote

Here we go, took me a while to find the old files. Too bad you can't see the animated effects, flash, or image roll overs. But this gives you an idea.

These two pages have multiple iFrames to make it easy to swap out pages and for quick editing.
http://img488.imageshack.us/my.php?image=usavoicewebsitetestsd7.jpg

http://img237.imageshack.us/my.php?image=btlswebsitetestor5.jpg

This was my first coding with CSS and required me to take a crash course in flash animation for the top bar. Also the whole page uses mostly PNGs for the effects.
http://img237.imageshack.us/my.php?image=siriusirpwebsitetestpo5.jpg

Rob
vedica



Joined: 23 Apr 2007
Posts: 11
Location: Noida, India

PostPosted: Wed May 02, 2007 10:42 pm     Reply with quote

haha Surprised kay, i uploaded a 1x1 blank gif image (i already had the Images directory, so I didnt have to do much )
here's how it looks now: http://www.freewebs.com/juhi21/index%5Fdummy%5Fframed%5Ffixed.htm
The images are perfect! Very Happy thanx! Very Happy
the iframes still have white backgrounds though.
but thanx!

hey, those websites are awesome! specially the sirius radio-station one...cool!
graphicsgod



Joined: 06 Feb 2007
Posts: 65

PostPosted: Thu May 03, 2007 12:22 pm     Reply with quote

I wouldn't use the transparent tag in the iFrame, just for that reason. I would use the background of the area to fill the background of the iFrame. That way it will work on more browsers and remove that problem.

Also cut up your background and insert it into tables or via CSS to allow faster loading and less problems. It may mean more work "now", but it will be better in the end!

Rob
graphicsgod



Joined: 06 Feb 2007
Posts: 65

PostPosted: Thu May 03, 2007 6:14 pm     Reply with quote

Ok I spent the last couple hours and fixed your website to work with a better system and keep everything looking and working how you want it to.

Check your email since I did more than just code Wink! You can change the images to your liking, I didn't have much to go on... so I made do Cool. I used winzip to put all the files into, FYI.

The whole site is using CSS and is all hacked up to load and be displayed better.

Enjoy!

Rob
vedica



Joined: 23 Apr 2007
Posts: 11
Location: Noida, India

PostPosted: Wed May 09, 2007 4:26 am     Reply with quote

hey! thats awesome!! i cant believ u recoded the whole thing! Very Happy gee thanx!
i think its a good idea to do it your way. its more browser compatible and seems better...and i seriously need to cut down on the loading time! i'll do it all over again following your way...thanx again! Very Happy
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Frame All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Webmaster Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial