iframe loading problem in IE

S

spinybabler

Hi,

I tired to load new page in iframe using something like this:
window.frames['my_frame'].location = "testpage.html"; and also
document.getElementById('my_frame').src = "testpage.html"; The thing
is it works fine in firefox but doesn't show anything in IE, no
errors nothing. I even tried calling window.frames
['my_frame'].location.reload() but to no avail. Eveen after calling
document.getElementById('my_frame').src = "testpage.html"; I tried
calling document.getElementById('my_frame').src
=document.getElementById('my_frame').src; . But it didn't work either.
I would greatly appreciate any help in this regard.

Thank you very much for your time.
 
E

Evertjan.

spinybabler wrote on 13 aug 2009 in comp.lang.javascript:
I tired to load new page in iframe using something like this:
window.frames['my_frame'].location = "testpage.html"; and also
document.getElementById('my_frame').src = "testpage.html"; The thing
is it works fine in firefox but doesn't show anything in IE, no
errors nothing. I even tried calling window.frames
['my_frame'].location.reload() but to no avail. Eveen after calling
document.getElementById('my_frame').src = "testpage.html"; I tried
calling document.getElementById('my_frame').src
=document.getElementById('my_frame').src; . But it didn't work either.
I would greatly appreciate any help in this regard.


<iframe name='my_frame'></iframe>

<script type='text/javascript'>
window.open('http://cnn.com','my_frame')
</script>
 
T

Thomas 'PointedEars' Lahn

spinybabler said:
I tired to load new page in iframe using something like this:
window.frames['my_frame'].location = "testpage.html"; and also
document.getElementById('my_frame').src = "testpage.html"; The thing
is it works fine in firefox but doesn't show anything in IE, no
errors nothing.

Unlikely, see the FAQ¹. Does it work with a `name' attribute instead of an
`id' attribute?
Thank you very much for your time.

You're welcome.


PointedEars
___________
¹ <http://jibbering.com/faq/#javascriptErrors>
 
S

spinybabler

spinybabler said:
I tired to load new page in iframe using something like this:
window.frames['my_frame'].location = "testpage.html";     and also
document.getElementById('my_frame').src = "testpage.html"; The thing
is  it works fine in firefox but doesn't show anything in IE, no
errors nothing.

Unlikely, see the FAQ¹.  Does it work with a `name' attribute insteadof an
`id' attribute?
Thank you very much for your time.

You're welcome.

PointedEars
___________
¹ <http://jibbering.com/faq/#javascriptErrors>
--
var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16

It has same name and ID but it doesn't work.
 
B

Bart Van der Donck

spinybabler said:
spinybabler said:
I tired to load new page in iframe using something like this:
window.frames['my_frame'].location = "testpage.html";     and also
document.getElementById('my_frame').src = "testpage.html"; The thing
is  it works fine in firefox but doesn't show anything in IE, no
errors nothing.
Unlikely, see the FAQ¹.  Does it work with a `name' attribute instead of an
`id' attribute?

It has same name and ID but it doesn't work.

I would probably go for

<iframe name="my_frame" id="my_frame"></iframe>
<script type="text/javascript">
frames["my_frame"].location.href = "http://www.cnn.com";
</script>

But I don't see why MSIE would error out on your

window.frames["my_frame"].location = "http://www.cnn.com";

Do you have a link where we can see your script in action ? That would
help.
 
T

Thomas 'PointedEars' Lahn

Bart said:
spinybabler said:
spinybabler wrote:
I tired to load new page in iframe using something like this:
window.frames['my_frame'].location = "testpage.html"; and also
document.getElementById('my_frame').src = "testpage.html"; The thing
is it works fine in firefox but doesn't show anything in IE, no
errors nothing.
Unlikely, see the FAQ¹. Does it work with a `name' attribute instead of an
`id' attribute?
It has same name and ID but it doesn't work.

I would probably go for

<iframe name="my_frame" id="my_frame"></iframe>
<script type="text/javascript">
frames["my_frame"].location.href = "http://www.cnn.com";
</script>

Which, by contrast, would

1. be subject to the Same Origin Policy,
2. introduce a DOM race condition,
3. assume `window' is the next object in the scope chain,

thus be likely _not_ to work. (Alternative content for the
`iframe' element is also missing.)
But I don't see why MSIE would error out on your

window.frames["my_frame"].location = "http://www.cnn.com";

Reviewing this, several reasons come to mind:

A) It is possible that the source document is accessed with a `file:' URI
and that scripting in general is not allowed for such documents in that
IE. IIRC, the default security setting for Active Scripting in the
"Local intranet" zone changed from "Enabled" in IE 6 to "Disabled" in
IE 7. Changing that setting (Tools, Internet Options, Security, Local
intranet, Custom Level, Active Scripting) would then solve the problem,
but introduce the security issue again.

B) The source document URL may be in the "Restricted sites" zone.

C) The target document URL may be in the "Restricted sites" zone.


PointedEars

P.S.: Your signature is borken.
 
S

spinybabler

Bart Van der Donck wrote:




spinybabler said:
On Aug 13, 1:02 pm, Thomas 'PointedEars' Lahn wrote:
spinybabler wrote:
I tired to load new page in iframe using something like this:
window.frames['my_frame'].location = "testpage.html";     and also
document.getElementById('my_frame').src = "testpage.html"; The thing
is  it works fine in firefox but doesn't show anything in IE, no
errors nothing.
Unlikely, see the FAQ¹.  Does it work with a `name' attribute instead of an
`id' attribute?
It has same name and ID but it doesn't work.
I would probably go for
   <iframe name="my_frame" id="my_frame"></iframe>
   <script type="text/javascript">
    frames["my_frame"].location.href = "http://www.cnn.com";
   </script>

Which, by contrast, would

1. be subject to the Same Origin Policy,
2. introduce a DOM race condition,
3. assume `window' is the next object in the scope chain,

thus be likely _not_ to work.  (Alternative content for the
`iframe' element is also missing.)
But I don't see why MSIE would error out on your
   window.frames["my_frame"].location = "http://www.cnn.com";

Reviewing this, several reasons come to mind:

A) It is possible that the source document is accessed with a `file:' URI
   and that scripting in general is not allowed for such documents inthat
   IE.  IIRC, the default security setting for Active Scripting in the
   "Local intranet" zone changed from "Enabled" in IE 6 to "Disabled"in
   IE 7.   Changing that setting (Tools, Internet Options, Security, Local
   intranet, Custom Level, Active Scripting) would then solve the problem,
   but introduce the security issue again.

B) The source document URL may be in the "Restricted sites" zone.

C) The target document URL may be in the "Restricted sites" zone.

PointedEars

P.S.: Your signature is borken.
--
var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16

Yes the file is accessed as using file: from local drive. But the
option (Active Scripting ) is enabled. I found that it works fine in
IE 7, the version that I was using to test was IE 6. Anyway making it
work in IE 7 is enough for me because main priority is Firefox. This
Javascript app has limited internal users so I don't have to bother
much about getting it right for every version of IE.

Anyway thanks a lot for your help and time. Those replied helped me
learn new things.
 
T

Thomas 'PointedEars' Lahn

kangax said:
Thomas said:
Bart Van der Donck wrote: [...]
I would probably go for

<iframe name="my_frame" id="my_frame"></iframe>
<script type="text/javascript">
frames["my_frame"].location.href = "http://www.cnn.com";
</script>
Which, by contrast, would
[...]
3. assume `window' is the next object in the scope chain,

I don't see where that assumption is being made. Could you please explain?

`frames' is defined as a host-defined property of Window objects,
not as a host-defined property of the Global Object. See also:

<https://developer.mozilla.org/en/DOM/window#Properties>
<http://msdn.microsoft.com/en-us/library/ms537459(VS.85).aspx>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top