By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,902 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

onclick event not working in Netscape 6

P: n/a
I have a <a> element in a datagrid which wraps some asp.net labels. this
element also has an onclick event which does not fire in netscape 6 (and
perhaps other browsers for all I know...). Below is the code for this. the
onclick event calls a javascript function which I put an alert in the firt
line to tell me if its working. It does work in IE. Any ideas on how to
get netcrap... oops, I'm sorry, netscape to fire the onclick event?
<a onclick='CartAdd(<%# DataBinder.Eval(Container.DataItem, "SKU1")%>)' >
<asp:Label id="lblItem1" runat="server" CssClass="clsGdChmNameStnd">
<%# DataBinder.Eval(Container.DataItem, "Item1")%>
</asp:Label><br>
<asp:Label id="lblSKU1" runat="server" CssClass="clsGdChmSKUStnd">sku: <%#
DataBinder.Eval(Container.DataItem, "SKU1")%> </asp:Label>
<br>
<asp:Label id="lblPrice1" runat="server" CssClass="clsGdChmSKUStnd">
<%# DataBinder.Eval(Container.DataItem, "Price1") %>
</asp:Label>
</a>
--
mo*******@nospam.com
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
turn on the javascript console in netscape to find out the scripting error,
or post the rendered html, so we can see the actual generated and called
script. whats the CartAdd script look like?

-- bruce (sqlwork.com)
"moondaddy" <mo*******@nospam.com> wrote in message
news:OW*************@TK2MSFTNGP09.phx.gbl...
I have a <a> element in a datagrid which wraps some asp.net labels. this
element also has an onclick event which does not fire in netscape 6 (and
perhaps other browsers for all I know...). Below is the code for this. the onclick event calls a javascript function which I put an alert in the firt
line to tell me if its working. It does work in IE. Any ideas on how to
get netcrap... oops, I'm sorry, netscape to fire the onclick event?
<a onclick='CartAdd(<%# DataBinder.Eval(Container.DataItem, "SKU1")%>)'

<asp:Label id="lblItem1" runat="server" CssClass="clsGdChmNameStnd">
<%# DataBinder.Eval(Container.DataItem, "Item1")%>
</asp:Label><br>
<asp:Label id="lblSKU1" runat="server" CssClass="clsGdChmSKUStnd">sku: <%# DataBinder.Eval(Container.DataItem, "SKU1")%> </asp:Label>
<br>
<asp:Label id="lblPrice1" runat="server" CssClass="clsGdChmSKUStnd">
<%# DataBinder.Eval(Container.DataItem, "Price1") %>
</asp:Label>
</a>
--
mo*******@nospam.com

Nov 18 '05 #2

P: n/a
OK sorry about that.

Here's the html it generated:

<a onclick='CartAdd(1588)' style="CURSOR: hand">
<span id="_ctl3_dgItems__ctl2_lblItem1"
class="clsGdChmNameStnd">Daisys</span><br>
<span id="_ctl3_dgItems__ctl2_lblSKU1" class="clsGdChmSKUStnd">sku:
1588</span>
<br>
<span id="_ctl3_dgItems__ctl2_lblPrice1"
class="clsGdChmSKUStnd">$18.00</span>
</a>
And here's the jscript function it calls:

<script language=jscript type=text/Jscript>
function CartAdd(value)
{
alert('hdSKU' );
_ctl3_hdSKU =value;
document.all('_ctl3_hdSKU').value =value;
document.all('_ctl3_btnPostBack').click();
}
</script>


--
mo*******@nospam.com
"bruce barker" <no***********@safeco.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
turn on the javascript console in netscape to find out the scripting error, or post the rendered html, so we can see the actual generated and called
script. whats the CartAdd script look like?

-- bruce (sqlwork.com)
"moondaddy" <mo*******@nospam.com> wrote in message
news:OW*************@TK2MSFTNGP09.phx.gbl...
I have a <a> element in a datagrid which wraps some asp.net labels. this element also has an onclick event which does not fire in netscape 6 (and
perhaps other browsers for all I know...). Below is the code for this.

the
onclick event calls a javascript function which I put an alert in the firt line to tell me if its working. It does work in IE. Any ideas on how to get netcrap... oops, I'm sorry, netscape to fire the onclick event?
<a onclick='CartAdd(<%# DataBinder.Eval(Container.DataItem, "SKU1")%>)'
<asp:Label id="lblItem1" runat="server" CssClass="clsGdChmNameStnd">
<%# DataBinder.Eval(Container.DataItem, "Item1")%>
</asp:Label><br>
<asp:Label id="lblSKU1" runat="server" CssClass="clsGdChmSKUStnd">sku:

<%#
DataBinder.Eval(Container.DataItem, "SKU1")%> </asp:Label>
<br>
<asp:Label id="lblPrice1" runat="server" CssClass="clsGdChmSKUStnd">
<%# DataBinder.Eval(Container.DataItem, "Price1") %>
</asp:Label>
</a>
--
mo*******@nospam.com


Nov 18 '05 #3

P: n/a
OK I fixed part of the problem, but I still need help. The part I fixed was
changing jscript to javascript in this line:
script language=jscript type=text/Jscript>

So now the onclick event fires and the alert in the function 'CartAdd' being
called runs, but at least part of the code doenst run after that. Whats
supposed to happen is the onclick event passes a SKU number as a parameter
into the function CartAdd. Then CartAdd put this value into a hidden
control and fires an OnClick event for a button to cause a postback. I'm
pretty sure there's no postback happening, but I'm not sure exactly where
the problem is. Here's the CartAdd function again, and the html for the
hidden element and the button for doing the postback. NOTE: all of this
works OK in IE 5+
<script language=javascript type=text/JavaScript>
function CartAdd(value)
{
alert('hdSKU' );
_ctl3_hdSKU =value;
document.all('_ctl3_hdSKU').value =value;
document.all('_ctl3_btnPostBack').click();
}
</script>
<input name="_ctl3:hdSKU" id="_ctl3_hdSKU" type="hidden" value="1588" /><br>
<input language="javascript" onclick="__doPostBack('_ctl3$btnPostBack','')"
name="_ctl3:btnPostBack" id="_ctl3_btnPostBack" type="button"
style="DISPLAY: none" value="PostBack" />

--
mo*******@nospam.com
"moondaddy" <mo*******@nospam.com> wrote in message
news:ul**************@TK2MSFTNGP11.phx.gbl...
OK sorry about that.

Here's the html it generated:

<a onclick='CartAdd(1588)' style="CURSOR: hand">
<span id="_ctl3_dgItems__ctl2_lblItem1"
class="clsGdChmNameStnd">Daisys</span><br>
<span id="_ctl3_dgItems__ctl2_lblSKU1" class="clsGdChmSKUStnd">sku:
1588</span>
<br>
<span id="_ctl3_dgItems__ctl2_lblPrice1"
class="clsGdChmSKUStnd">$18.00</span>
</a>
And here's the jscript function it calls:

<script language=jscript type=text/Jscript>
function CartAdd(value)
{
alert('hdSKU' );
_ctl3_hdSKU =value;
document.all('_ctl3_hdSKU').value =value;
document.all('_ctl3_btnPostBack').click();
}
</script>


--
mo*******@nospam.com
"bruce barker" <no***********@safeco.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
turn on the javascript console in netscape to find out the scripting

error,
or post the rendered html, so we can see the actual generated and called
script. whats the CartAdd script look like?

-- bruce (sqlwork.com)
"moondaddy" <mo*******@nospam.com> wrote in message
news:OW*************@TK2MSFTNGP09.phx.gbl...
I have a <a> element in a datagrid which wraps some asp.net labels. this element also has an onclick event which does not fire in netscape 6 (and perhaps other browsers for all I know...). Below is the code for this.

the
onclick event calls a javascript function which I put an alert in the firt line to tell me if its working. It does work in IE. Any ideas on how to get netcrap... oops, I'm sorry, netscape to fire the onclick event?
<a onclick='CartAdd(<%# DataBinder.Eval(Container.DataItem, "SKU1")%>)'
<asp:Label id="lblItem1" runat="server" CssClass="clsGdChmNameStnd">
<%# DataBinder.Eval(Container.DataItem, "Item1")%>
</asp:Label><br>
<asp:Label id="lblSKU1" runat="server"
CssClass="clsGdChmSKUStnd">sku: <%#
DataBinder.Eval(Container.DataItem, "SKU1")%> </asp:Label>
<br>
<asp:Label id="lblPrice1" runat="server" CssClass="clsGdChmSKUStnd">
<%# DataBinder.Eval(Container.DataItem, "Price1") %>
</asp:Label>
</a>
--
mo*******@nospam.com



Nov 18 '05 #4

P: n/a
I'm not sure that this is the problem ... but you can try to replace with
this :
document.all['_ctl3_hdSKU'].value =value;
document.all['_ctl3_btnPostBack'].click();

this code is used for?
_ctl3_hdSKU =value;
Brun

"moondaddy" <mo*******@nospam.com> wrote in message
news:ec*************@TK2MSFTNGP10.phx.gbl...
OK I fixed part of the problem, but I still need help. The part I fixed was changing jscript to javascript in this line:
script language=jscript type=text/Jscript>

So now the onclick event fires and the alert in the function 'CartAdd' being called runs, but at least part of the code doenst run after that. Whats
supposed to happen is the onclick event passes a SKU number as a parameter
into the function CartAdd. Then CartAdd put this value into a hidden
control and fires an OnClick event for a button to cause a postback. I'm
pretty sure there's no postback happening, but I'm not sure exactly where
the problem is. Here's the CartAdd function again, and the html for the
hidden element and the button for doing the postback. NOTE: all of this
works OK in IE 5+
<script language=javascript type=text/JavaScript>
function CartAdd(value)
{
alert('hdSKU' );
_ctl3_hdSKU =value;
document.all('_ctl3_hdSKU').value =value;
document.all('_ctl3_btnPostBack').click();
}
</script>
<input name="_ctl3:hdSKU" id="_ctl3_hdSKU" type="hidden" value="1588" /><br> <input language="javascript" onclick="__doPostBack('_ctl3$btnPostBack','')" name="_ctl3:btnPostBack" id="_ctl3_btnPostBack" type="button"
style="DISPLAY: none" value="PostBack" />

--
mo*******@nospam.com
"moondaddy" <mo*******@nospam.com> wrote in message
news:ul**************@TK2MSFTNGP11.phx.gbl...
OK sorry about that.

Here's the html it generated:

<a onclick='CartAdd(1588)' style="CURSOR: hand">
<span id="_ctl3_dgItems__ctl2_lblItem1"
class="clsGdChmNameStnd">Daisys</span><br>
<span id="_ctl3_dgItems__ctl2_lblSKU1" class="clsGdChmSKUStnd">sku:
1588</span>
<br>
<span id="_ctl3_dgItems__ctl2_lblPrice1"
class="clsGdChmSKUStnd">$18.00</span>
</a>
And here's the jscript function it calls:

<script language=jscript type=text/Jscript>
function CartAdd(value)
{
alert('hdSKU' );
_ctl3_hdSKU =value;
document.all('_ctl3_hdSKU').value =value;
document.all('_ctl3_btnPostBack').click();
}
</script>


--
mo*******@nospam.com
"bruce barker" <no***********@safeco.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
turn on the javascript console in netscape to find out the scripting

error,
or post the rendered html, so we can see the actual generated and called script. whats the CartAdd script look like?

-- bruce (sqlwork.com)
"moondaddy" <mo*******@nospam.com> wrote in message
news:OW*************@TK2MSFTNGP09.phx.gbl...
> I have a <a> element in a datagrid which wraps some asp.net labels.

this
> element also has an onclick event which does not fire in netscape 6 (and > perhaps other browsers for all I know...). Below is the code for this. the
> onclick event calls a javascript function which I put an alert in the
firt
> line to tell me if its working. It does work in IE. Any ideas on
how
to
> get netcrap... oops, I'm sorry, netscape to fire the onclick event?
>
>
> <a onclick='CartAdd(<%# DataBinder.Eval(Container.DataItem,

"SKU1")%>)'
>
> <asp:Label id="lblItem1" runat="server"

CssClass="clsGdChmNameStnd"> > <%# DataBinder.Eval(Container.DataItem, "Item1")%>
> </asp:Label><br>
> <asp:Label id="lblSKU1" runat="server"

CssClass="clsGdChmSKUStnd">sku: <%#
> DataBinder.Eval(Container.DataItem, "SKU1")%> </asp:Label>
> <br>
> <asp:Label id="lblPrice1" runat="server" CssClass="clsGdChmSKUStnd"> > <%# DataBinder.Eval(Container.DataItem, "Price1") %>
> </asp:Label>
> </a>
>
>
> --
> mo*******@nospam.com
>
>



Nov 18 '05 #5

P: n/a
Bruno,

document.all is only supported in IE. Netscape uses document.layers.
Heres a simple browser detection script:

The most common pattern in JavaScript scripts is probably the section
that determines the browser type. And its structure is probably
something like:

<SCRIPT LANGUAGE="JavaScript">
<!--
if (document.all) {
document.write("Internet Explorer Detected");
}
else if (document.layers) {
document.write("Netscape Navigator Detected");
}
else {
document.write("Unrecognized Browser Detected");
}
// -->
</SCRIPT>

Full link to code excerpt above:
http://webreference.com/js/tips/001125.html

If you store the browser variable in a global variable, you can use it
in an if statement in your function to ensure your modifying the right
values:

isIE = (document.all);

if (isIE)
{
document.all('_ctl3_hdSKU').value =value;
document.all('_ctl3_btnPostBack').click();
}
else
{
//do something else here.. not sure how to get to your field and
button in Netscape (document.layers leads nowhere I believe) - maybe
document.forms[form index].elements[field/button index]? - that is
cross browser compliant.
}

My 2 cents...

J'son

"Bruno Sirianni" <br***********@virgilio.it> wrote in message news:<LP**********************@news3.tin.it>...
I'm not sure that this is the problem ... but you can try to replace with
this :
document.all['_ctl3_hdSKU'].value =value;
document.all['_ctl3_btnPostBack'].click();

this code is used for?
_ctl3_hdSKU =value;
Brun

"moondaddy" <mo*******@nospam.com> wrote in message
news:ec*************@TK2MSFTNGP10.phx.gbl...
OK I fixed part of the problem, but I still need help. The part I fixed

was
changing jscript to javascript in this line:
script language=jscript type=text/Jscript>

So now the onclick event fires and the alert in the function 'CartAdd'

being
called runs, but at least part of the code doenst run after that. Whats
supposed to happen is the onclick event passes a SKU number as a parameter
into the function CartAdd. Then CartAdd put this value into a hidden
control and fires an OnClick event for a button to cause a postback. I'm
pretty sure there's no postback happening, but I'm not sure exactly where
the problem is. Here's the CartAdd function again, and the html for the
hidden element and the button for doing the postback. NOTE: all of this
works OK in IE 5+
<script language=javascript type=text/JavaScript>
function CartAdd(value)
{
alert('hdSKU' );
_ctl3_hdSKU =value;
document.all('_ctl3_hdSKU').value =value;
document.all('_ctl3_btnPostBack').click();
}
</script>
<input name="_ctl3:hdSKU" id="_ctl3_hdSKU" type="hidden" value="1588"

/><br>
<input language="javascript"

onclick="__doPostBack('_ctl3$btnPostBack','')"
name="_ctl3:btnPostBack" id="_ctl3_btnPostBack" type="button"
style="DISPLAY: none" value="PostBack" />

--
mo*******@nospam.com
"moondaddy" <mo*******@nospam.com> wrote in message
news:ul**************@TK2MSFTNGP11.phx.gbl...
OK sorry about that.

Here's the html it generated:

<a onclick='CartAdd(1588)' style="CURSOR: hand">
<span id="_ctl3_dgItems__ctl2_lblItem1"
class="clsGdChmNameStnd">Daisys</span><br>
<span id="_ctl3_dgItems__ctl2_lblSKU1" class="clsGdChmSKUStnd">sku:
1588</span>
<br>
<span id="_ctl3_dgItems__ctl2_lblPrice1"
class="clsGdChmSKUStnd">$18.00</span>
</a>
And here's the jscript function it calls:

<script language=jscript type=text/Jscript>
function CartAdd(value)
{
alert('hdSKU' );
_ctl3_hdSKU =value;
document.all('_ctl3_hdSKU').value =value;
document.all('_ctl3_btnPostBack').click();
}
</script>


--
mo*******@nospam.com
"bruce barker" <no***********@safeco.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
> turn on the javascript console in netscape to find out the scripting error, > or post the rendered html, so we can see the actual generated and called > script. whats the CartAdd script look like?
>
> -- bruce (sqlwork.com)
>
>
> "moondaddy" <mo*******@nospam.com> wrote in message
> news:OW*************@TK2MSFTNGP09.phx.gbl...
> > I have a <a> element in a datagrid which wraps some asp.net labels. this > > element also has an onclick event which does not fire in netscape 6 (and > > perhaps other browsers for all I know...). Below is the code for this.
the > > onclick event calls a javascript function which I put an alert in the
firt > > line to tell me if its working. It does work in IE. Any ideas on how
to > > get netcrap... oops, I'm sorry, netscape to fire the onclick event?
> >
> >
> > <a onclick='CartAdd(<%# DataBinder.Eval(Container.DataItem, "SKU1")%>)' > >
> > <asp:Label id="lblItem1" runat="server" CssClass="clsGdChmNameStnd"> > > <%# DataBinder.Eval(Container.DataItem, "Item1")%>
> > </asp:Label><br>
> > <asp:Label id="lblSKU1" runat="server" CssClass="clsGdChmSKUStnd">sku:
<%# > > DataBinder.Eval(Container.DataItem, "SKU1")%> </asp:Label>
> > <br>
> > <asp:Label id="lblPrice1" runat="server" CssClass="clsGdChmSKUStnd"> > > <%# DataBinder.Eval(Container.DataItem, "Price1") %>
> > </asp:Label>
> > </a>
> >
> >
> > --
> > mo*******@nospam.com
> >
> >
>
>


Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.