Page 1 of 1

IE-Compatible JavaScript Not Working In IE?

Posted: Sat Jan 14, 2006 6:56 pm
by IceMetalPunk
I have just created this code for InvisionFree that creates a new section of the Compose PM screen if the member is trying to PM the administrator.

Everything used in the script should be IE-compatible, yet although the script works fine in NetScape, it causes an "Unknown Runtime Error" in IE.
Here is the script:

Code: Select all

<script language="JavaScript" type="text/JavaScript">

function SetPMName() {
if (document.REPLIER.from_contact) { document.REPLIER.entered_name.value=document.REPLIER.from_contact.options[document.REPLIER.from_contact.selectedIndex].text; }
ShowOptions();
}

function CheckOpts() {
if (mytr.style.display!="none") {
document.REPLIER.msg_title.value=document.REPLIER.adminopts.options[document.REPLIER.adminopts.selectedIndex].text+": "+document.REPLIER.msg_title.value;
}
return true;
}

function ShowOptions() {

namer="IceMetalPunk";

if (document.REPLIER.entered_name.value.toLowerCase()==namer.toLowerCase()) { okay=""; } else { okay="none"; }
mytr.style.display=okay;
mytr2.style.display=okay;
}

if (window.location.href.toLowerCase().indexOf("act=msg")!=-1) {

trs=document.getElementsByTagName("tr");
for (p=0; p<trs.length; p++) {
if (trs[p].innerHTML.toLowerCase().indexOf("enter your message")!=-1 && trs[p+1].innerHTML.toLowerCase().indexOf("message title")!=-1) {

mytr=trs[p+2].parentNode.insertRow(trs[p+2].rowIndex);
mytr2=trs[p+3].parentNode.insertRow(trs[p+3].rowIndex);
mytr.innerHTML="<td colspan='2' class='pformstrip'>Administrator PM Options</td>";
mytr2.innerHTML="<td class='pformleft'><b>Select Purpose of PM</b></td><td class='pformright'><select name='adminopts'><option>Other</option><option>Personal PM</option><option>Board PM</option><option>Forum Bug</option><option>Board Skin</option></select></td>";
mytr.style.display="none";
mytr2.style.display="none";
}
}

if (document.REPLIER.from_contact) { document.REPLIER.from_contact.setAttribute("onChange","SetPMName()"); }
document.REPLIER.entered_name.setAttribute("onBlur","ShowOptions()");
document.REPLIER.setAttribute("onSubmit","return CheckOpts()");
SetPMName();
}
</script>
Can anyone please help me pinpoint the line(s) that is/are causing the error, since "unknown runtime error" doesn't give me much help?

BTW, all of the functions used there are documented on MSDN as IE-Compatible, AFAIK....

-IMP ;) :)

Posted: Sat Jan 14, 2006 7:56 pm
by feyd
ahem, moved to Client Side.

Posted: Sat Jan 14, 2006 9:28 pm
by IceMetalPunk
Sorry, I didn't see that forum. And, it wasn't moved, so if it would help my question get answered, could someone please move it?

I thought you all should know I got rid of the error (but using insertCell instead of putting the <td>'s in the rows directly), but now there's another problem.

setAttribute with the onBlur event doesn't seem to work in IE (although it works for onSubmit in IE).

I found the function attachEvent, so I tried this code:

Code: Select all

if (navigator.appName.toLowerCase().indexOf("internet explorer")!=-1) {
document.REPLIER.entered_name.attachEvent("onBlur",ShowOptions);
document.REPLIER.attachEvent("onSubmit",CheckOpts);
}
else {
document.REPLIER.entered_name.setAttribute("onBlur","ShowOptions()");
document.REPLIER.setAttribute("onSubmit","return CheckOpts()");
}
Although there is no error, it still does not attach the functions to the events in IE.

Any help here, please, someone?

-IMP ;) :)

Posted: Tue Jan 17, 2006 4:41 pm
by IceMetalPunk
Nevermind, got this one working... please close/delete this topic. Thanks.

-IMP ;) :)