javascript works in Firefox but not in IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dorandoran
    New Member
    • Feb 2007
    • 145

    javascript works in Firefox but not in IE

    view source for I.E. and firefox shows following
    Code:
    <script src="script.js" type="text/javascript"></script>
    but only working in firefox. Getting "object expected" error for internet explorer.

    I am using masterpage so I am registering the script.js on load of the content page.

    Code:
    ClientScriptManager Jscript = Page.ClientScript;
    Jscript.RegisterClientScriptInclude(this.GetType(), "ScriptInFile","script.js");
  • dorandoran
    New Member
    • Feb 2007
    • 145

    #2
    call me crazy but all of the sudden it's working in both IE and Firefox. (well, I basically restarted the IIS, the asp.net built in IIS). and I checked the box "Always display something something" when I javascript error happend "object expected", after that it started working. I then went to IE > tools> internet options > advanced > and unchecked the "Display a notification about every script error.".

    then I went back to browser and checked the functionality and they seem to be working both in IE and Firefox.

    I still want to learn what fixed my IE issue. I understand IE and firefox handles javascript differently.

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5390

      #3
      currently you just avoid the error-notification in IE, and i strongly guess that the error comes from the script itself ... not simply from the include ... so to say something, we would need to know what the script will do and see the code to tell you what could be wrong ...

      kind regards

      Comment

      • dorandoran
        New Member
        • Feb 2007
        • 145

        #4
        Firefox works as expected. IE is only displaying fname not the contenate name. Also, no alert is pops up with IE.

        This is my script.js

        Code:
        function openMyWindow()
        { 
            var myID = document.getElementById('ctl00_maincontent_txtEmpID').value;
            var sName = document.getElementById('ctl00_maincontent_txtfname').value & " " & document.getElementById('ctl00_maincontent_txtlname').value;
            var url = 'assign_dept.aspx?id='+myID+'&sName='+ sName;
            alert(sName);
            window.open(url,'welcome','width=400,height=250');
        }
        Here is the link
        Code:
        <a href="javascript:;" onclick="openMyWindow();return false">Open My Window</a>

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          in your line 4 fix the concatenation of the string ...

          kind regards

          Comment

          Working...