Forum Moderators: open

Message Too Old, No Replies

Graphics On/Off option detector (JavaScript)

Help, please. I promptly need to know it...

         

Dezmond

3:23 pm on Aug 2, 2006 (gmt 0)

10+ Year Member



Hello!

Sorry for my english. I'm from Ukraine and know english language at low level...

I have one little problem.

How I can detect Graphics On/Off option in browser settings?

I need to make web-site, which opens the non-graphics page first time and check graphics on/off mode. Afterward if graphics is on in browser settings, script must redirect user to a graphical variant of web-page.

Please, help...

Thank you in advance

Fotiman

5:18 pm on Aug 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't know if you can reliably test this. My best guess would be to try creating a really small image in JavaScript, and then see if the width is not zero.


var testImages = new Image();
testImages.src = "1x1px.gif";
if( testImages.width == 0 )
{
// Images are not being loaded
}

Again, I don't know if that works for all browsers or how reliable it is.

Dezmond

8:48 am on Aug 3, 2006 (gmt 0)

10+ Year Member



Thanks.

Your script code lets me create a new, more intelligent script.

So, look at this:

...
<script language="javascript">

function check_graphics_mode()
{
if(check_img.complete) {... re-direct page ...};
}

</script>
...
<body onLoad="check_graphics_mode()">
<img src="1x1_transparent.png" name="check_img">

....

</body>
...

More simple, more intelligent I mean..
What do you think about it?

Fotiman

1:35 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




<script language="javascript">

function check_graphics_mode()
{
if(check_img.complete) {... re-direct page ...};
}

</script>
...
<body onLoad="check_graphics_mode()">
<img src="1x1_transparent.png" name="check_img">



More simple, more intelligent I mean..
What do you think about it?

Actually, I prefer my method. The reason being that this method requires that you have some image rendered, even if it does nothing. You then have to account for this image in all of your page flows. It's more intrusive because you now rely on some external content from the script, whereas my method does not actually need to render the image and doesn't affect any of the other flow of the document.