mosaic.js button onclick better IE workaroud

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
Albert
Cone that earned his stripes
Cone that earned his stripes
Posts: 102
Joined: 15 Mar 2006 08:17

mosaic.js button onclick better IE workaroud

Postby Albert » 29 Mar 2006 19:59

Hello,
I found better IE workaround for creating button with onclick function:
Do not call function create_button( caption, action )...
Please test it with Mozilla family browsers.

Original code mosaic.js:

Code: Select all

var id = x+'_'+y; var melt = create_button( cells[id] ? cells[id] : '?', 'mosaic_elt_choose(\"'+id+'\");' ); melt.setAttribute( 'id', id ); melt.setAttribute( 'title', 'Click to choose stream' ); mcell.appendChild( melt ); mrow.appendChild( mcell );
New code:

Code: Select all

var id = x+'_'+y; var melt = document.createElement("input"); melt.setAttribute('type', 'button'); melt.setAttribute( 'id', id ); melt.setAttribute( 'title', 'Click to choose stream' ); melt.setAttribute('value', cells[id] ? cells[id] : '?'); melt.setAttribute("onclick",function(){mosaic_elt_choose(id);}); mcell.appendChild( melt ); mrow.appendChild( mcell );
Albert
Last edited by Albert on 29 Mar 2006 20:05, edited 1 time in total.

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 29 Mar 2006 20:03

does that automatically replace id with it's value ?
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

Albert
Cone that earned his stripes
Cone that earned his stripes
Posts: 102
Joined: 15 Mar 2006 08:17

:-(

Postby Albert » 29 Mar 2006 20:21

Hello,
I am sorry, id for onclick are all the same - the highest values.
Albert

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 29 Mar 2006 21:52

that's why i had to do my ugly hack ... the DOM way of doing it was great ... but IE didn't like it.
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 29 Mar 2006 21:53

By the way, do you want to be added to the THANKS file ? (since you helped me with lots of bug fixes in the http interface you deserve it)
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

Albert
Cone that earned his stripes
Cone that earned his stripes
Posts: 102
Joined: 15 Mar 2006 08:17

workaround

Postby Albert » 29 Mar 2006 22:18

Hello,
I didn´t noticed comments in create_button()...

I found some workarounds, but mostly uglier :)
I suppose there is a bug(s) in IE. elm.setAttribute() is not working in the right way and all attributes set before appendChild() to the root element are lost (=sets the last value to all).
So I see a way to rewrite mosaic table into 2 for cycles: 1st creates the table and appends it to the document element; 2nd cycle sets attributes (id, onclick) to the allready created and affiliated table cells.

I haven´t tested this yet. I can try tomorow. But... it could be longer code than your workaround... is this advisable?


I do not object to be added to thanks file :-)
Albert

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 30 Mar 2006 02:02

I think that i'll keep current code since it works :)

Could you give me your full name for the thanks file ? (and email if you want ... but use a private message if you do to prevent spam)
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 1 guest