Closed Thread Icon

Topic awaiting preservation: removing an attribute in IE?? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8266" title="Pages that link to Topic awaiting preservation: removing an attribute in IE?? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: removing an attribute in IE?? <span class="small">(Page 1 of 1)</span>\

 
genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-20-2002 01:19

i just have no luck with names in IE.

I can't remove the name attribute from anything in IE.

bSuccess = object.removeAttribute("name") doesn't work.
object.removeAttribute("name") doesn't work.

I even tried doing some of that dadfangled persistent data stuff in the DOM ref on MSDN.
However, that only made my head hurt.

Does anyone know how to remove attributes in IE. . . i mean moogity jeebus!!


bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 08-20-2002 01:30

Umm er nope but I gotta ask why and/or why just setting the name to nothing or false won't work.



.:[ Never resist a perfect moment ]:.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-20-2002 02:23

because if you don't get rid of a name in an input, when you post it in a form with GET method, it gives

page?goodvar=25&=blah&=moreblah

rather than

page?goodvar=25

well it posts like that in IE , not Moz. Good old Moz.
/me gives Moz a tasty treat.

edit: Oh wait, yeah... moz posts like dat too. but at least the removeAttribute can take care of that in Moz.


[This message has been edited by genis (edited 08-20-2002).]

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-20-2002 05:33

oh please... i know there are people out there smarter than me.

i mean... miracles do happen.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-20-2002 07:21

well great.
apparently removeAttribute("name") does work in IE on simple scripts like this:

code:
function removeAttrib() {
myDIV = document.getElementById("myDIV");
myDIV.removeAttribute("name");
}



but not inside this for loop for some reason:

code:
opts = document.getElementsByTagName("input");
for(var i=0; i<opts.length; i++) {
iD = opts[i].id;
regArr = reg.exec(iD);
if(regArr[0] == num) {
opts[i].style.backgroundColor = defBg;
opts[i].style.color = defTxt;
opts[i].setAttribute("name", "");
opts[i].removeAttribute("name");
}
}



*bangs head against wall*

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 08-20-2002 14:09

I'm just a newbie but maybe you need to set a name attribute at this line:
opts[i].setAttribute("name", "");

like

opts[i].setAttribute("name", "your_name");

dunno though.

_________________
http://hzr.dzygn.com

hlaford
Bipolar (III) Inmate

From: USA! USA! USA!
Insane since: Oct 2001

posted posted 08-20-2002 15:34

how about not setting the name in the first place... you can still use an id to access the control via javascript.

i guess the browser registers the form control for submission when the page loads rather than right at the time of submission.

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 08-20-2002 18:24

Hmm, yea, when I look at it, why setting a name attribute and the directly remove it?

_________________
http://hzr.dzygn.com

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-20-2002 20:31

well i'm setting the name attribute there for IE.
I have to zero it out some way because IE won't delete the name attribute.

Then I have the removeAttribute right after it because Moz does remove it correctly.
If I didn't, Moz would post it the same ugly way IE does.

Which is what I'm trying to avoid.

All of this wouldn't matter if I was posting with the POST method instead of GET, but it's really a non-issue at this point, I guess I'm just trying to see if anyone knows why IE sucks so bad.

Genevieve
Paranoid (IV) Inmate

From: Santa Clara, CA, USA
Insane since: Jul 2002

posted posted 08-20-2002 20:42

According to webmonkey's Thau! ( http://hotwired.lycos.com/webmonkey/98/03/index3a_page5.html ) THIS should work:

window.open("some_url","window_name",
"location=no,status=no");

That's just an example. So whatever you are trying to turn off, just put "attribute=no"

I think that's what you're asking about.

Genevieve Hokanson
Student Intern, GPB
http://einstein.stanford.edu
http://www.geocities.com/genevievescu/

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-20-2002 21:51

no i'm pretty sure that would just make the name "no"

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-20-2002 21:57

Where's Doc, he's the javascript master, right?

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 08-20-2002 22:31

no, you must be thinking of Slime..


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-20-2002 22:57

I just skimmed this, but if it helps, I'm aware of some IE bugs where changing an attribute of an element with setAttribute has no effect, especially when it's the "class" attribute. The line

if (elem.innerHTML) elem.innerHTML=elem.innerHTML;

where elem is an ancestor of the troublesome element, seems to workaround the bug.

DocOzone
Maniac (V) Lord Mad Scientist
Sovereign of all the lands Ozone and just beyond that little green line over there...

From: Stockholm, Sweden
Insane since: Mar 1994

posted posted 08-21-2002 00:02

Wow, my head hurt just thinking about this, I always just avoid situations like that if things don't work elegantly first time around. (Patented DocOzone? methodology! :-) As I understand it, you have a form that people will submit, but you only want it to pass along one of the variables, not all of them in a big ugly string, right? My solution would be to simply not use the "submit" function at all, instead just make it a type=button, and have an onClick attribute that will get the next page, appending the one value you want to send along to the next page.

ie:

function fakeSubmit() {
location.href = "nextPage.html?goodvar="+ document.formName.goodvar.value;
}

...and then in your html form...

<input type="button" value="submit" onClick="fakeSubmit()">

...you could also check the 'goodvar' input to see if it'd been filled in or not at this point and then do something else (like an alert() or something). Personally, I've been doing a lot of work with HTML forms lately for one of my clients, and I usually avoid the submit function altogether, I feel it gives me more control of what's happening.

Or did I misunderstand your problem? I didn't answer your question, but this should be a good workaround. As Petskull mentioned, Slime is the one who knows all, I just have a knack with quick hacks. ;-)

Your pal, -doc-

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 08-21-2002 00:17

Perhaps if you posted the whole page so we know what you are trying to do we'd have an easier time.




.:[ Never resist a perfect moment ]:.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-21-2002 02:03

Hey, thanks for all your help.

bitdamaged, it's the same deal i was working in an earlier post, just a new problem.

Here's the old code --> sweetastic.com/selectBox.html

I went with slime's workaround and it works! (kinda... only in IE actually, thus detection oh well. )

Here's the new code with the workaround --> sweetastic.com/selectBox-2.html

Anywhoo, it doesn't quite work with multiple select boxes in one form yet, but I'll hope to have that done in a bit.

Thanks for all your help fellow asylum dwellers!

edit: I spelled asylum wrong... i must be losing it.




[This message has been edited by genis (edited 08-21-2002).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-21-2002 02:43

Might I suggest you use the built-into-html <select> tag?

BTW, use the if (elem.innerHTML) rather than if (document.all) since there are browsers (mainly Mozilla) that support innerHTML but not document.all, and this should work on them too.

I can guarantee that this won't work on NN 4.x; that's hopeless.

What other browsers fail?

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-21-2002 03:07

uggh... the whole reason i started this was to specifically NOT use the <select> tag.
Because browsers don't allow you to change the boxes asthetically enough using CSS
(borders can't be widened, doesn't look slick, etc).

yeesh.

Okay, i'll use that instead of document.all.

I don't care about any other browsers except IE/Moz and especially not anything less than the equivalent 5.x browsers.
I used to care about Opera, but no longer do because I can't see any benefit it provides over Moz 1+.
I wouldn't support IE either if 98% of web surfers didn't use it.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-21-2002 03:53

Allright! Final code is up for that.

Lookit here --> sweetastic.com/ozone/selectBox-2.html

I used (document.body.innerHTML) instead and used elem.parentNode to fix the multiple box thing.
I'll just use this for all my select boxes now!

Thanks for the help everyone!
It was super-enlightening.

« BackwardsOnwards »

Show Forum Drop Down Menu