Get img from cell in Firefox

Get img from cell in Firefox

am 02.04.2008 22:30:07 von joe

Hello all!

I'm trying to change the src of imgs in 5 different cells so I iterate
through the cells in the table and do this:
var img = table.rows[0].cells[n].firstChild;
img.src = some url

This works fine in IE but not in any other browser. What's the trick here?

Thanks,
Joe

Re: Get img from cell in Firefox

am 02.04.2008 22:47:54 von joe

Actually I guess it's rendered as an input. I'm using ImageButtons that I'm
trying to change.

"Joe" wrote in message
news:exTjkCQlIHA.1188@TK2MSFTNGP04.phx.gbl...
> Hello all!
>
> I'm trying to change the src of imgs in 5 different cells so I iterate
> through the cells in the table and do this:
> var img = table.rows[0].cells[n].firstChild;
> img.src = some url
>
> This works fine in IE but not in any other browser. What's the trick here?
>
> Thanks,
> Joe
>

Re: Get img from cell in Firefox

am 02.04.2008 23:30:30 von joe

Now it looks like my problem is I cannot get/set the title.

"Joe" wrote in message
news:exTjkCQlIHA.1188@TK2MSFTNGP04.phx.gbl...
> Hello all!
>
> I'm trying to change the src of imgs in 5 different cells so I iterate
> through the cells in the table and do this:
> var img = table.rows[0].cells[n].firstChild;
> img.src = some url
>
> This works fine in IE but not in any other browser. What's the trick here?
>
> Thanks,
> Joe
>

Re: Get img from cell in Firefox

am 03.04.2008 05:15:58 von stcheng

Hi Joe,

As for loop through all the image(or other html elements in a html table),
I would suggeest you use the "document.getElementByTagName" function as
it's the standard DOM interface which works on both IE and firebox. The "
table.rows[0].cells[n].firstChild;" syntax is somewhat coupled with IE
browser. Here is a simple test page demonstrate this:

===========================================

Untitled Page




















image: src="http://www.asp.net/App_Themes/Standard/i/logo.png" />
image: src="http://static.asp.net/asp.net/images/books/book13.gif" />
image: />




onclick="get_img_in_table('tbImages');" />



==============================================

BTW, for your new question about setting the "title", would you tell me
what' the title you mentioned? is it the page title or title of some other
html element on page?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx .
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Joe"
>References:
>Subject: Re: Get img from cell in Firefox
>Date: Wed, 2 Apr 2008 17:30:30 -0400
>
>Now it looks like my problem is I cannot get/set the title.
>
>"Joe" wrote in message
>news:exTjkCQlIHA.1188@TK2MSFTNGP04.phx.gbl...
>> Hello all!
>>
>> I'm trying to change the src of imgs in 5 different cells so I iterate
>> through the cells in the table and do this:
>> var img = table.rows[0].cells[n].firstChild;
>> img.src = some url
>>
>> This works fine in IE but not in any other browser. What's the trick
here?
>>
>> Thanks,
>> Joe
>>
>
>
>

Re: Get img from cell in Firefox

am 03.04.2008 07:39:38 von marss

On 2 Кві, 23:30, "Joe" wrote:
> Hello all!
>
> I'm trying to change the src of imgs in 5 different cells so I iterate
> through the cells in the table and do this:
> var img =3D table.rows[0].cells[n].firstChild;
> img.src =3D some url
>
> This works fine in IE but not in any other browser. What's the trick here?=

>
> Thanks,
> Joe

Hi Joe,

Little addition to the Steven's post.
document.getElementsByTagName("IMG") returns all images on a page.
table, tr, td elements also have getElementsByTagName method and you
can reduce result images set if you use it.

Regarding of firstChild.
In Firefox it depends on HTML structure, if there is a gap between td
and img tags then the first child is a text node.
1. 2.
Regards,
Mykola
http://marss.co.ua

Re: Get img from cell in Firefox

am 03.04.2008 18:06:39 von joe

The getElemenetByTagName worked to fix my issue. Thanks.

"Steven Cheng [MSFT]" wrote in message
news:eDhGNvTlIHA.4932@TK2MSFTNGHUB02.phx.gbl...
> Hi Joe,
>
> As for loop through all the image(or other html elements in a html table),
> I would suggeest you use the "document.getElementByTagName" function as
> it's the standard DOM interface which works on both IE and firebox. The "
> table.rows[0].cells[n].firstChild;" syntax is somewhat coupled with IE
> browser. Here is a simple test page demonstrate this:
>
> ===========================================
>
> Untitled Page
>
>
>
>


>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
image: > src="http://www.asp.net/App_Themes/Standard/i/logo.png" />
image: > src="http://static.asp.net/asp.net/images/books/book13.gif" />
image: > />

>
>

> > onclick="get_img_in_table('tbImages');" />
>

>

>
> ==============================================
>
> BTW, for your new question about setting the "title", would you tell me
> what' the title you mentioned? is it the page title or title of some other
> html element on page?
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx .
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> --------------------
>>From: "Joe"
>>References:
>>Subject: Re: Get img from cell in Firefox
>>Date: Wed, 2 Apr 2008 17:30:30 -0400
>>
>>Now it looks like my problem is I cannot get/set the title.
>>
>>"Joe" wrote in message
>>news:exTjkCQlIHA.1188@TK2MSFTNGP04.phx.gbl...
>>> Hello all!
>>>
>>> I'm trying to change the src of imgs in 5 different cells so I iterate
>>> through the cells in the table and do this:
>>> var img = table.rows[0].cells[n].firstChild;
>>> img.src = some url
>>>
>>> This works fine in IE but not in any other browser. What's the trick
> here?
>>>
>>> Thanks,
>>> Joe
>>>
>>
>>
>>
>

Re: Get img from cell in Firefox

am 04.04.2008 04:49:02 von stcheng

Thanks for your reply Joe,

I'm glad that it helps you.

Have a nice day!

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
========================================
>From: "Joe"
>References:


>Subject: Re: Get img from cell in Firefox
>Date: Thu, 3 Apr 2008 12:06:39 -0400

>
>The getElemenetByTagName worked to fix my issue. Thanks.
>
>"Steven Cheng [MSFT]" wrote in message
>news:eDhGNvTlIHA.4932@TK2MSFTNGHUB02.phx.gbl...
>> Hi Joe,
>>
>> As for loop through all the image(or other html elements in a html
table),
>> I would suggeest you use the "document.getElementByTagName" function as
>> it's the standard DOM interface which works on both IE and firebox. The "
>> table.rows[0].cells[n].firstChild;" syntax is somewhat coupled with IE
>> browser. Here is a simple test page demonstrate this:
>>
>> ===========================================
>>
>> Untitled Page
>>
>>
>>
>>


>>

>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
image: >> src="http://www.asp.net/App_Themes/Standard/i/logo.png" />
image: >> src="http://static.asp.net/asp.net/images/books/book13.gif" />
image: >> />

>>
>>

>> >> onclick="get_img_in_table('tbImages');" />
>>

>>

>>
>> ==============================================
>>
>> BTW, for your new question about setting the "title", would you tell me
>> what' the title you mentioned? is it the page title or title of some
other
>> html element on page?
>>
>> Sincerely,
>>
>> Steven Cheng
>>
>> Microsoft MSDN Online Support Lead
>>
>>
>> Delighting our customers is our #1 priority. We welcome your comments and
>> suggestions about how we can improve the support we provide to you.
Please
>> feel free to let my manager know what you think of the level of service
>> provided. You can send feedback directly to my manager at:
>> msdnmg@microsoft.com.
>>
>> ==================================================
>> Get notification to my posts through email? Please refer to
>>
http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
>> ications.
>>
>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
>> where an initial response from the community or a Microsoft Support
>> Engineer within 1 business day is acceptable. Please note that each
follow
>> up response may take approximately 2 business days as the support
>> professional working with you may need further investigation to reach the
>> most efficient resolution. The offering is not appropriate for situations
>> that require urgent, real-time or phone-based interactions or complex
>> project analysis and dump analysis issues. Issues of this nature are best
>> handled working with a dedicated Microsoft Support Engineer by contacting
>> Microsoft Customer Support Services (CSS) at
>> http://msdn.microsoft.com/subscriptions/support/default.aspx .
>> ==================================================
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> --------------------
>>>From: "Joe"
>>>References:
>>>Subject: Re: Get img from cell in Firefox
>>>Date: Wed, 2 Apr 2008 17:30:30 -0400
>>>
>>>Now it looks like my problem is I cannot get/set the title.
>>>
>>>"Joe" wrote in message
>>>news:exTjkCQlIHA.1188@TK2MSFTNGP04.phx.gbl...
>>>> Hello all!
>>>>
>>>> I'm trying to change the src of imgs in 5 different cells so I iterate
>>>> through the cells in the table and do this:
>>>> var img = table.rows[0].cells[n].firstChild;
>>>> img.src = some url
>>>>
>>>> This works fine in IE but not in any other browser. What's the trick
>> here?
>>>>
>>>> Thanks,
>>>> Joe
>>>>
>>>
>>>
>>>
>>
>
>
>