Detexting if IFRAMEs enabled

G

Giggle Girl

Is there a way to use Javascript to detect if a browser supports
IFrames, or (if it DOES support them) that IFrame use is enabled?

Thanks,
Ann
 
S

Stephen Chalmers

Giggle said:
Is there a way to use Javascript to detect if a browser supports
IFrames, or (if it DOES support them) that IFrame use is enabled?

Thanks,
Ann

I can't guarantee this universally, but you could try something like:

<iframe src='mypage.htm'>
<script type='text/javascript'>
var ifSupport=false;
</script>
</iframe>

<script type='text/javascript'>
// must be placed below iframe tags or
// called as onload code.

if( typeof ifSupport != 'undefined' )
// iframes supported
else
// alert or redirect etc

</script>
 
T

Thomas 'PointedEars' Lahn

Stephen said:
Giggle said:
Is there a way to use Javascript to detect if a browser supports
IFrames, or (if it DOES support them) that IFrame use is enabled?
[...]

Signatures are not to be quoted unless explicitly referred to.
I can't guarantee this universally, but you could try something like:

<iframe src='mypage.htm'>
<script type='text/javascript'>
var ifSupport=false;
</script>
</iframe>

<script type='text/javascript'>
// must be placed below iframe tags or
// called as onload code.

if( typeof ifSupport != 'undefined' )
// iframes supported
else
// alert or redirect etc

</script>

That is essentially the same as

<iframe src='mypage.htm'>
<script type='text/javascript'>
var ifSupport=false;
// iframes supported
</script>
</iframe>

<script type='text/javascript'>
// iframes not supported
if (typeof ifSupport == 'undefined')
{
// alert or redirect etc
}
</script>

Yet it will still not work without client-side script support.

Signatures must be delimited with a line containing
(in words, not literally) MinusMinus_Space_Newline.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Giggle said:
Is there a way to use Javascript to detect if a browser supports
IFrames, or (if it DOES support them) that IFrame use is enabled?

As Stephen wrote: yes, there is. But not considering that
client-side script support may not be present, why would you
need to?

<iframe src='mypage.htm' ...>
alternative content
</iframe>

works fine. Everywhere, anytime.


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

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top