473,320 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

does browser support an image using style ?

MV
How do I check if a browser supports an image using style before
writing it with document.write?

document.write("<img id='picture1' src='a.gif' alt='blah'
style='blah'>");
NN4 and Opera 6 throw a wobbler.

Also, what way is best to reference it?
document.getElementById('picture1')
or
document.images['picture1']
Jul 20 '05 #1
2 1217
On 4 Mar 2004 18:41:40 -0800, MV <mi*************@yahoo.com> wrote:
How do I check if a browser supports an image using style before
writing it with document.write?
You can't. Browsers don't (at least generally) contain feature flags.
You'll just have to hope.

Don't forget, CSS and JavaScript are in the same catagory: support for
both is *optional*.
document.write("<img id='picture1' src='a.gif' alt='blah'
style='blah'>");
NN4 and Opera 6 throw a wobbler.
How do define, "a wobbler"? Do they ignore the style, or do they do
something worse like crash? If it's the former, you shouldn't worry. As
long as the content is still readable, that's all that is important[1].
You shouldn't strive for your pages to look exactly the same in all
browsers as it's not just possible, especially when the browsers in
question are outdated.
Also, what way is best to reference it?
document.getElementById('picture1')
or
document.images['picture1']


You can use both, but the latter is more widely supported.

var imgRef = null;

if( document.getElementById ) {
imgRef = document.getElementById( 'picture1' );
} else if( document.images ) {
imgRef = document.images[ 'picture1' ];
}

if( imgRef ) {
// Got a reference to the image
}

Mike
[1] You should, after all, make sure that pages are usable with CSS and
JavaScript disabled, when possible. They probably won't be pretty though,
but it's the content that's the most important.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
MV
Michael Winter <M.******@blueyonder.co.invalid> wrote in message news:<op**************@news-text.blueyonder.co.uk>...
How do define, "a wobbler"? Do they ignore the style, or do they do
something worse like crash? If it's the former, you shouldn't worry. As
long as the content is still readable, that's all that is important[1].
You shouldn't strive for your pages to look exactly the same in all
browsers as it's not just possible, especially when the browsers in
question are outdated.
Also, what way is best to reference it?
document.getElementById('picture1')
or
document.images['picture1']


You can use both, but the latter is more widely supported.

var imgRef = null;

if( document.getElementById ) {
imgRef = document.getElementById( 'picture1' );
} else if( document.images ) {
imgRef = document.images[ 'picture1' ];
}

if( imgRef ) {
// Got a reference to the image
}

Mike
[1] You should, after all, make sure that pages are usable with CSS and
JavaScript disabled, when possible. They probably won't be pretty though,
but it's the content that's the most important.


Sorry Michael, I had a tantrum instead of checking things out
properly. It was nothing to do with style, here's what I had:

document.write("<img id='picture1' src='a.gif' alt='blah'
style='blah'>");
var X=document.getElementById('picture1');
or
var X=document.images['picture1'];

Rest of script............

In Opera 6, X was undefined. However, if put into an 'initialize'
function then X returns as expected - [object - whatever].

I've decided not to bother with NN4 but I don't want to cause a page
freeze should someone still have it.

I agree with your last point but in this case, the script is the only
content.

Thanx for your time.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Saqib Ali | last post by:
Please excuse me, this is a fairly involved question that will likely require you to save the file below to a file and open it in a browser. I use Mozilla 1.5, so the problem I describe below...
2
by: John | last post by:
The following code works OK in IE 6.0 but does not work in Netscape 7. The image does not shift when one scrolls down but stays stationary in Netscape. Please help Thank you John function...
17
by: lawrence | last post by:
How is it possible that the question "How do I detect which browser the user has" is missing from this FAQ: http://www.faqts.com/knowledge_base/index.phtml/fid/125 and is only here on this...
1
by: prasaddevivara | last post by:
I am using the outerHTML property to modify the HTML of existin elements in a web page in Internet Explorer. But same outerHTM property is not working in firefox browser, Anybody can tell me a...
4
by: Peter Larsen | last post by:
Hi, I want to be able to show a file browser embedded on a form - a browser which is similar to the browser you get by SHBrowseForFolder(). Is that possible ? Thank you in advance. BR Peter...
10
by: Viken Karaguesian | last post by:
Hello everyone, Me again. Trying to learn some more :>) I hope I got the terminology right. How does a browser parse (correct term?) an HTML document. I'm sure that every browser does it a...
18
by: damezumari | last post by:
I would like to know how many of the visitors to my site has js enabled and how many has it turned off. I haven't found a simple solution searching Google groups so I suggest the following using...
2
by: webdeveloper | last post by:
sorry about that, This is the event handling element: <div id="menu"> <ul> <li>.... <li><a href="javascript:expand_menu(document.getElementById('extend'))" id="extend">Text <img src=""...
1
by: jonathanellis | last post by:
Hello: I am having a problem with a web site that i built not showing up properly in IE6. I haven't tested it in IE7, but I have tested it in Firefox and Safari. Both Firefox and Safari show the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.