Click here to Skip to main content
15,889,751 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I am having an problem that my javascript code runs only in an mozilla but not in google chrome and IE.please tell whould i do sothat in it can run in all major browsers..
This is search which page which open up on button on another page
<script type="text/javascript">
C#
$(document).ready(function() {

            $('.btnSelectCSS').click(function() {
                var pmxid = $(this).attr("PMXId");
                var name = $(this).attr("FullName");
                //alert(pmxid);
                //window.opener.document.aspnetForm.ctl00_contentArea_txtlinemanager.value = pmxid;
                //var dataArray = [pmxid, pmxname];

                //                    if (window.opener) {
                //                        window.opener.returnValue = dataArray;
                //                    }
                window.returnValue = [pmxid, name];
                window.close();
            });
        });
    </script>


Below is the code behind of above page

C#
if (selectButton != null && employee != null)
           {
               string javascript = string.Format("javascript:SelectPMxId({0},{1});", employee.PMxId, employee.FullName);

            employee.PMxId);
               selectButton.Attributes.Add("onClick", javascript);

           }



And below is the where i need to call this page..
XML
<script type="text/javascript">
        function OpenPopup(showPopupFor) {
            var popupGenerator = null;
            var trusteeName = null;
            var empidhiddenfield = null;
            var trustnamehiddenfield = null;
            popupGenerator = document.getElementById("<%= txtlinemanager.ClientID %>");
            trusteeName = document.getElementById("<%= txtTrusteeName.ClientID %>");
            empidhiddenfield = document.getElementById("<%= textlinemangr.ClientID %>");
            trustnamehiddenfield = document.getElementById("<%= texttrustname.ClientID %>")



            if (popupGenerator == null) return false;
            var url = "masterdata/employee/employeesearch.aspx";
            var params = new Array(popupGenerator.Value);
            var popupSetting = "center:yes;scroll:no;edge=raised;status:no;resizable:no;dialogWidth:400px;dialogHeight:415px";
            var prevReturnValue = window.returnValue;
            window.returnValue = undefined;
            var pmx = window.showModalDialog(url, params, popupSetting);
            if (pmx == undefined) {
                pmx = window.returnValue;
            }
            window.returnValue = prevReturnValue;
            if (pmx == undefined || pmx == null) {
                popupGenerator.value = "";
            }
            else {
                // popupGenerator.value = pmx.toString();
                popupGenerator.value = pmx[0].toString();
                trusteeName.value = pmx[1].toString();
                empidhiddenfield.value = pmx[0].toString();
                trustnamehiddenfield.value = pmx[1].toString();
            }
            //popupGenerator.focus();
            return false;
        }

    </script>

please tell me how should i do this to work it fine..
Posted

1 solution

change this line from

C#
string javascript = string.Format("javascript:SelectPMxId({0},{1});", employee.PMxId, employee.FullName);

to
C#
string javascript = string.Format("javascript:SelectPMxId('{0}','{1}');", employee.PMxId, employee.FullName);</pre>
as



employee.FullName is a string value, it should be passed within quotes. else it wont be considered as a value.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900