Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1026 How can I display one image if the browser supports image swapping and other if it doesn't?

You are here: irt.org | FAQ | JavaScript | Image | Q1026 [ previous next ]

One way:

<SCRIPT LANGUAGE="JavaScript"><!--
if (document.images)
    document.write('<IMG SRC="javascriptenabled.gif" WIDTH="100" HEIGHT="100">');
else
    document.write('<IMG SRC="javascriptdisabled.gif" WIDTH="100" HEIGHT="100">');
//--></SCRIPT>

<NOSCRIPT>
<IMG SRC="javascriptdisabled.gif" WIDTH="100" HEIGHT="100">
</NOSCRIPT>

Alternatively:

<IMG NAME="myImage" SRC="javascriptdisabled.gif" WIDTH="100" HEIGHT="100">

<SCRIPT LANGUAGE="JavaScript"><!--
if (document.images)
    document.images.myImage.src = 'javascriptenabled.gif';
//--></SCRIPT>

©2018 Martin Webb