Click to See Complete Forum and Search --> : javascript problem with different browser


naina rani
09-30-2004, 12:57 PM
I have two problems in my web application:

1. I am using javascript to hide file field .The way it works is,when you click on the radio button it will display the hidden fields.It works fine with Internet Explorer,its not working with mozilla

javascript code:
function openXmlpageField()
{
blnMoreIsUp = true;
document.all.item("MORE2", 0).style.visibility = blnMoreIsUp ? "" : "hidden";
}

within jsp:
<table>
<tr>
<td width="255"><bean:message key="prompt.appl.Xmlpage"/></td>
<td> <input type="radio" name="image"onClick="openXmlpageField()"/>select</td>
</tr>
</table>
<div id=MORE2 style="visibility: hidden">
<table>
<tr><td width="330">ý</td>
<td><html:file property="image" size="40"/></td>
</tr>
</table>
</div>

2.I have script to popup a different window and display html file when you click on the radion button.
javascript code :

function openPopup3(){
var popurl="foldername/filename.html"
winpops=window.open(popurl,"","width=400,height=400,scrollbars,")
}

this is fine with IE .When I try on Mozilla it complains about the relative path that I have mentioned in the script.
Mozilla recgonizes it this way

[url]http://localhost/applicationname/foldername/foldername/filename.html

Is relative path different for different browser?
I want my application to work with almost all browsers.Please help me to make it work with Mozilla.

sciguyryan
09-30-2004, 01:04 PM
Well, if the problem is the relative path then why not use a ful path URL instead?


RyanJ

JPnyc
09-30-2004, 01:54 PM
Because that's IE only syntax you're using. It will never work in a gecko browser.

document.all.item("MORE2", 0).style.visibility

Only IE and some versions of Opera understand document.all

Vince
09-30-2004, 08:39 PM
I think the previous poster is right the "document.all" is spesific to IE, you might want to try changing one line I havn't checked it out but am sure that it will work

document.getElementBYId("MORE2").style.visibility = blnMoreIsUp ? "" : "hidden";

V

sciguyryan
10-02-2004, 06:32 AM
Well, there is a way to simulate the IE document.all syntax in NN but, its complicated to use.


RyanJ

JPnyc
10-02-2004, 07:44 AM
Why bother? IE understands getElementById

sciguyryan
10-02-2004, 08:41 AM
Originally posted by DUNSEL
Why bother? IE understands getElementById


True, but some peopel (I suppose) just like consistency in their coding. Anyway incase you'r interested here is the code:


<script type="text/javascript">
<!--
if (!document.all){
Node.prototype.__defineGetter__("all", function(){
if (document.getElementsByTagName("*").length){
switch (this.nodeType){
case 9:
return document.getElementsByTagName("*");
break;
case 1:
return this.getElementsBya=TagName("*");
break;
}
}
return "";
})
Node.prototype.__defineSetter__("all", function() {});
}
//-->
</script>




RyanJ

JPnyc
10-02-2004, 09:04 AM
Very clever bit of coding, but as you said, it's too convoluted to bother with and just not needed anymore.

sciguyryan
10-02-2004, 09:07 AM
Originally posted by DUNSEL
Very clever bit of coding, but as you said, it's too convoluted to bother with and just not needed anymore.


Clever coding Yes, useful not really. I'd agree with you and always use document.getEleemntById() anyway as I see no need to use anything else.


RyanJ

JPnyc
10-02-2004, 09:10 AM
However I would've liked to have known about it about 6-7 yrs ago.

sciguyryan
10-02-2004, 09:16 AM
Originally posted by DUNSEL
However I would've liked to have known about it about 6-7 yrs ago.

I coulden't code anything 6-7 years ago. I only started JS later last year and then PHP this year.


RyanJ

JPnyc
10-02-2004, 09:18 AM
Actually, come to think of it, I wasn't in IT then either. I was a musician.

naina rani
10-05-2004, 04:57 PM
Thanks a lot.

document.getElementById(....) is working.