By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,341 Members | 1,396 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,341 IT Pros & Developers. It's quick & easy.

Detexting if IFRAMEs enabled

P: n/a
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

Dec 1 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Giggle Girl wrote:
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>

--
S.C.

Dec 2 '05 #2

P: n/a
Stephen Chalmers wrote:
Giggle Girl wrote:
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.
<URL:http://jibbering.com/faq/faq_notes/pots1.html>
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.
--
S.C.


Signatures must be delimited with a line containing
(in words, not literally) MinusMinus_Space_Newline.
PointedEars
Dec 2 '05 #3

P: n/a
Giggle Girl wrote:
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
Dec 2 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.