Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Changing iframe src results in a blank iframe on IE6
Old 03-07-2007, 02:30 PM Changing iframe src results in a blank iframe on IE6
foobar's Avatar
Extreme Talker

Posts: 225
Trades: 0
OK, I've been banging my head against the wall on this one for hours.

I have a page which contains an iframe. The iframe initially contains a blank page. When the page loads, I use window.frames["frameName"].location.src = newSource; to change the page in the iframe. Firefox does this no problem.

On IE6 however, the blank page is there (I added some text in the blank .html to check). When I change the iframe src, all I get is a blank page. Not the page I want it to load.

Before changing the src, I've setup alerts to show me what the current src is, and what the new one is going to be. I see those fine. But for some reason, IE refuses to load the correct page.

Any help would be greatly appreciated.
foobar is offline
Reply With Quote
View Public Profile Visit foobar's homepage!
 
 
Register now for full access!
Old 03-07-2007, 06:04 PM Re: Changing iframe src results in a blank iframe on IE6
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Well, I've never tried this, but now I'm curious.

How many people view your site using IE 6? If FireFox and the current version of Internet Explorer both run your code properly, maybe the next question is whether it's worth changing?

That said, iframes mean multi pages in the same browser window, so if you're trying to change the source of one frame from another, that might be your problem. Could you instead cause that frame to navigate to a new URL by itself? What triggers the navigation?
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 03-08-2007, 04:05 AM Re: Changing iframe src results in a blank iframe on IE6
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Maybe try to use DOM functions to update it.
And an iframe is not like a browser windows.
You don't use location.src, but you must alter the src property of the iframe tag.

And on a side not, if I remember right, location.src is deprecated.
You should use window.location=url now.
look there: http://developer.mozilla.org/en/docs...indow.location
There is no more src property nor method. the location.src method yould stop working on a future update of the navigators.

But to our concern now, I just tried this on my comp, and it's working ok.
I've got ie7, but this should work no different in ie6.

Code:
<body>
  beginning<hr>
  <iframe src="blank.html" width=100 height=100 id="myIframe"></iframe>
  <hr>
  end<br>
  <a href="javascript:changeIframe();" >test</a>
  <script type="text/javascript">
    function changeIframe(){
      document.getElementById('myIframe').src="success.html";
    }
  </script>
</body>
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 03-08-2007 at 04:11 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-08-2007, 05:58 AM Re: Changing iframe src results in a blank iframe on IE6
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
That works.
I figured another method, don't know if it's good or not.

Code:
<body>
<iframe src="1.html" id="frame"></iframe>
<a href="javascript:change();" >test</a>
<script type="text/javascript">
function change(){
document.getElementById('frame').setAttribute("src","2.html");
}
</script>
</body>
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Insensus is offline
Reply With Quote
View Public Profile
 
Old 03-08-2007, 12:32 PM Re: Changing iframe src results in a blank iframe on IE6
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
In a DOM way , I'd say that your method is even more right than mine.
I don't know how much it's portable though.

I have used the method I told before for at least 2 years, and I know it's crossbrowser, so I didn't looked much further.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-08-2007, 02:40 PM Re: Changing iframe src results in a blank iframe on IE6
foobar's Avatar
Extreme Talker

Posts: 225
Trades: 0
I found the problem.

On page load, one of the functions was writing a style sheet <link /> into the iframe window.

It seems that on IE.... it breaks iframes. I didn't delve any further into the problem and removed the style sheet, since whatever page gets included in there can simply specify its own.

Thanks for the replies.
foobar is offline
Reply With Quote
View Public Profile Visit foobar's homepage!
 
Old 03-09-2007, 07:40 AM Re: Changing iframe src results in a blank iframe on IE6
logic ali's Avatar
Super Talker

Posts: 104
Trades: 0
Quote:
Originally Posted by foobar View Post
I found the problem.

On page load, one of the functions was writing a style sheet <link /> into the iframe window.

It seems that on IE.... it breaks iframes. I didn't delve any further into the problem and removed the style sheet, since whatever page gets included in there can simply specify its own.

Thanks for the replies.
Code:
window.frames["frameName"].location.href=newURL;
logic ali is offline
Reply With Quote
View Public Profile
 
Old 03-09-2007, 02:31 PM Re: Changing iframe src results in a blank iframe on IE6
foobar's Avatar
Extreme Talker

Posts: 225
Trades: 0
Quote:
Originally Posted by logic ali View Post
Code:
window.frames["frameName"].location.href=newURL;
I fail to see what you're trying to point out here...
foobar is offline
Reply With Quote
View Public Profile Visit foobar's homepage!
 
Old 03-09-2007, 03:03 PM Re: Changing iframe src results in a blank iframe on IE6
logic ali's Avatar
Super Talker

Posts: 104
Trades: 0
Quote:
Originally Posted by foobar View Post
I fail to see what you're trying to point out here...
Just the answer to your question. That's the syntax to use.
logic ali is offline
Reply With Quote
View Public Profile
 
Old 03-09-2007, 03:32 PM Re: Changing iframe src results in a blank iframe on IE6
foobar's Avatar
Extreme Talker

Posts: 225
Trades: 0
The syntax I had up there at first worked. Yours would to. My problem was with the stylesheet being written on load.

Thanks though.
foobar is offline
Reply With Quote
View Public Profile Visit foobar's homepage!
 
Reply     « Reply to Changing iframe src results in a blank iframe on IE6
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32024 seconds with 12 queries