Onclick javascript function not working in ie11 Nov 4, 2015 · I have strange problems with my (ASP. I need to assign an onclick event to a CheckBoxFor in ASP. This is in my header <script type="text/javascript"> function this_function () { alert ("got While this function is defined in index. yeh the older version of IE sometimes not firing the onChange event and replacing it with onClick works. attachEvent and addEventListener are necessary. The onchange handler is not appropriate in this case since the value of the input does not change, only the checked/unchecked attribute. Aug 22, 2017 · I am having a hard time figuring out how to use a click event on IE11. I am having a const function need to execute on a div item (child-component) on the left side, which consists Description The onclick event occurs when the user clicks on an HTML element. Apr 2, 2012 · <select> <option onclick="check()">one</option> <option onclick="check()">two</option> <option onclick="check()">three</option> </select>` onclick event is not working on IE and Chrome but it is working fine in firefox, here I don't want to use onchange event on select tag bcz it will not trigger an event if user selects same option again Eg:say first time user selects "one" dropdown I will Provides solutions for resolving issues with the JavaScript method window. Chrome, FF, Safari = no issues, only problem as usually is IE. Any user interaction that is equivalent to a click, such as pressing the Space key or Enter key while the element is focused. So, let’s dive into the specific solutions and get your scripts up and running! Jul 16, 2024 · A notable example is Internet Explorer, which has garnered a reputation for its discrepancies in JavaScript execution and compatibility. all(81). In forms, the 'button' tag does not return the value correctly for form submission. Is the Javascript loaded correctly? Is there any other code that might be messing things up? onclick="AddPrinter()" I didn't find much about this when searching on Google for an hour. I'm not sure how your workaround would help in that regard, since the UI would be completely frozen while the function executes and events would just get queued until they can be handled properly. Fix your broken code and get your website working again today! However, when monitoring traffic with Fiddler, several random IE spans don’t trigger the javascript function at all. You are correct. How does it know whether you're calling the function from javascript or vbscript or whatever anyway? I get this error: Learn how to get the ID of a clicked button using onClick event in JavaScript. What change will be required? <html:select mu May 18, 2015 · The onClientClick event is not getting fired in IE11 browser, however the same piece of code is working perfectly fine in IE8,9 and 10 browsers. Apr 26, 2017 · This doesn't answer the question, but have you considered using a pure JavaScript event handler instead, rather than embedding the onclick event into your HTML? Mar 24, 2022 · The code posted looks correct. IE's handling of <option> elements is off in a lot of ways, the source of which is that IE's select boxes are native Windows widgets, not objects implemented by the browser. js as every other feature of my app works. Please let me know how to solve this problem. it seems that Edge can not manage structured data objects like arrays, so that the asp pages working in IE browser, do not in Edge. Jun 17, 2020 · So we have deployed the IE mode within Edge, successfully to a group of pilot users. Onclick requires a mouse action where off course on the phone Feb 3, 2024 · Scope Your Functions Properly: Make sure your functions are defined in the scope from which you’re trying to access them. The idea of the function is to format the input string to capitalise the first letter of each word, and put a period after each word. My html code calls a shortcut as follows: Feb 5, 2005 · what's totally weird about this is that when i change 'onclick' to 'onmouseover', the script works in Internet Explorer too. But it does not seem to work in IE 11. log it displays the element in all the browsers I have tried (including Microsoft Edge) and they do not display any errors. Mar 1, 2018 · I'm trying to add a submit function in my HTML and refer to a js file with my function. Note that this only A couple of concerns for me with respect to using string escape in onClick and as the number of arguments grow, it will become cumbersome to maintain. All buttons on the page that respond to the onclick event stop wor Feb 20, 2023 · I must migrate old asp pages containing javascript code. The question does not have to be directly related to Linux and any language is fair game. What I did find didn't work. The you can get the id as event. Feb 20, 2023 · I must migrate old asp pages containing javascript code. write ("testing") below the loop in the javascript, which had no effect, which makes me think the function is not being called at all. Oct 12, 2010 · We have a problem in IE with some users where the onclick event isn't working: Jul 23, 2025 · The onclick event handler is a built-in function in JavaScript used to manage how DOM elements respond when clicked by the user. And semicolons are not needed as well if an explicit line break is not needed. Then that function gets assigned to the respective handler property for that element. Nov 3, 2023 · Hi Raina, I think the shortcut is opening kiosk mode and ie mode ok, but part of my code is not working when used with the fullscreen option. The error message is "submitFunc (event) is undefined". Apr 29, 2024 · In Chrome the above code works just fine, although in Microsoft Edge the click () method does not seem to work for some reason. We can also use the JavaScript’s addEventListener () method and pass a click event to it for greater flexibility. Find answers to Javascript onclick function not working in IE from the expert community at Experts Exchange Learn how to fix the 'onclick not working' JavaScript error in 3 steps. In the main it is working very well, however on some websites, we have some very specific issues with certain elements on a page not working despite the page correctly launching in IE11 mode. setAttribute() command; you just have to position them properly within your JavaScript code. back() not functioning as expected. * Get step-by-step instructions with code examples. open () function working properly on chrome but do not work on IE and Firefox, Is there any alternate to this function. You can use the analogous attachEvent (which has slightly different syntax) in IE <9. Perhaps the browser is caching the image since you're not changing the img src to something new. But not working at all in IE6. cursor="pointer";}; </script> This works PERFECT in FF and IE8. But this is not expected with latest IE 11. I'm baffled at this one. I just changed it to some other name which should sound like unique in the whole context Oct 4, 2017 · The web site not working in most windows PC in chrome, firefox and IE after open the message source i found the below code for the submit button but its inside iframe May 4, 2012 · This is because the two anonymous functions are completely different functions. The same Oct 23, 2012 · 0 Same answer I used here Javascript onclick functions do not work should apply. What causes this? I have windows 10 and everything i Aug 5, 2016 · But anyway that's not my problem. I faced an issue in a case where creating multiple buttons in a loop and assigning a function for onclick for each button in the loop was not working. js. Similar to the post linked, when I refresh the page the link does work and the modal opens. How do you add onClick event in HTML? It means we cannot apply the onclick event on the given tags. Works perfectly fine with Google Chrome. Nov 3, 2025 · The method addEventListener() works by adding a function, or an object that implements a handleEvent() function, to the list of event listeners for the specified event type on the EventTarget on which it's called. Click is not working for some reason. This works fine in FireFox I can see it going through all of the other functions in the other onclick s using Developer Tools and stepping through the page it does not submit the results of goStep3 until it has gone through all of the other onclick functions on the page. I know the function I want to execute: exportData (workOrderSearchForm), but don't know how to do so outside of using the "click" method. It also provides a cleaner way to add more arguments Apr 19, 2022 · Pop-ups not working in Edge - IE Mode In preparation for IE Retirement, We pushed a GP update for Edge so that our application will continue to function. Mar 25, 2010 · Inner function definitions are used to create function objects which are assigned to properties of the Variable object with names that correspond to the function name used in the function declaration. Sep 25, 2025 · An element receives a click event when any of the following occurs: A pointing-device button (such as a mouse's primary button) is both pressed and released while the pointer is located inside the element. I am not sure what pitfalls there are to avoid, and I am not currently able to test implementations in any other browsers than Internet Ex Jan 26, 2016 · In Internet Explorer it is only fired if I refresh the page (F5). Sep 4, 2020 · I need to open a div on click of an image, so for this I simply created an onclick event for a function within image tag. I like that when you click the image, that javascript method showSomeInfo () is called. Could anyone explain me what makes the code doesn't work? I know the solution for this is probably to use addEventListener, but why doesn't this work? Possible duplicate of JavaScript button onclick not working, but this question only suggests the solution not explaining the reason. My code works with chrome, firefox but does not work in Internet Explorer 11. May 22, 2018 · onClick not working for my button Asked 7 years, 5 months ago Modified 6 years, 9 months ago Viewed 3k times Feb 1, 2008 · Javascript onclick doesn't work in IE Programming This forum is for all programming questions. I've added an example script to address the previous value. Define your functions before you use them. This quick and easy guide will help you get your onclick events working again in no time. But the problem is that it works in all browsers except IE 8. Apr 2, 2012 · <select> <option onclick="check()">one</option> <option onclick="check()">two</option> <option onclick="check()">three</option> </select>` onclick event is not working on IE and Chrome but it is working fine in firefox, here I don't want to use onchange event on select tag bcz it will not trigger an event if user selects same option again Eg:say first time user selects "one" dropdown I will Oct 28, 2014 · I got a script for a quantity box where you can add or remove items. Thanks Zeeshan Sep 30, 2017 · as a part of my Django app, I have a small js code that works fine in Chrome, but I just noticed that it is not working in IE or Microsoft Edge. The code runs successfully in Chrome but not in IE11. Oct 28, 2014 · I got a script for a quantity box where you can add or remove items. Thanks for any responds! in the HTML) work is, they take the text within the attribute and generate a function using that text as the function's body. This comprehensive guide will help you troubleshoot the issue and get your code working Apr 4, 2024 · A step-by-step illustrated guide on how to resolve the issue where the onclick event doesn't work in JavaScript or React. See full list on 10scopes. Jun 26, 2006 · I am having a link on the page which says "add tab" o clicking this link I add a new tab to the page, I write the code for that in Javascript function, I set the attributes of that tab in there. The code basically looks lets the uder pick a card, if it has, it chooses another card that hasn't been picked, and then adds it too an array. getAttribute("id"); so you do not need a seperate variable to exist. Aug 6, 2015 · The problem is that in IE onclick event does not trigger any action, but how to debug it, if console is empty? I added A HTML tags, the function trigger is always added dynamically over DOM, so onclick event is not visible in HTML code. Aug 18, 2014 · Where is that FillSubDropdownlist() function you are referring to defined? If the code is set up properly, that part should make the city dropdown box display once you have selected a valid country fom the country dropdown box. history. Using field is better solution because then also double quotes can be used like normally in HTML. It allows you to attach a function to be executed when a user clicks on a specific HTML element, such as a button. The application URL was added to open in IE compatibility mode and it is working fine, performing different functions on the site opens a pop-up window. 1. some pieces are left outand some others are unimportant May 21, 2012 · I'm 100% sure it's not working (i put alerts in every step of the onclick function) but strangely there's not javascript errors when i debug the script. Works fine with Chrome and FireFox on the same machine ! I am trying to make a javascript function work on pressing search button but the function doesnt seem to run. Jun 16, 2009 · This will modify the prototype of the Event and add this function, a great feature of javascript/DOM in general. Learn how to fix onclick javascript not working with these easy steps. Jun 22, 2010 · a_butt. close() or javascript:self. click-method is NOT fired. preventDefault with no problem. net web app, and encountered a jQuery or JavaScript issue. At a certain point the onclick event stops working. Please help Jan 21, 2023 · Hi, I'm working on a ASP. Nov 7, 2015 · Im trying to call a function when user clicks on the navbar search button but it does not seem to call the javascript fuction and just loads the same page. But when clicking on HTML button, the onclick looks for function inside bundle. Does it work if you call the function manually from the console? Dec 17, 2012 · This code below works in every other browser bar IE. If I open this page in IE 8, clicking on the image does nothing and I'm not sure why. This guide will help you troubleshoot the issue and get your onclick events working again in no time. Understanding the onclick Event The essential of interactivity in web development, the onclick event triggers a JavaScript function when a Since your first option doesn't work, I'm guessing function 1 blocks the main thread while it executes. Jun 11, 2014 · javascript function internet-explorer-8 onclick edited Jun 11, 2014 at 20:29 asked Jun 11, 2014 at 19:28 user2588440 Jan 15, 2016 · A way that it seems to work, would be like this I add the element using document. Using 0 for the timeout doesn’t actually mean that the Mar 17, 2012 · So inconsistent logic in IE. . I have looked at examples and other quest Jul 14, 2010 · ie. Aug 8, 2013 · While you don't need the javascript: part, it should still execute. The problem is: I want to do this - when a button is clicked, trigger a javascript function to do a certain task, but for some reason this particular function is not… Apr 9, 2024 · Uncover the secrets to optimizing JavaScript for Internet Explorer, tackling compatibility issues and mastering best practices for cross-browser functionality. Pasting code directly to webViewer is not recommended. In HTML, we can use the onclick attribute and assign a JavaScript function to it. Though others work, adding a function directly to onclick may not work in some scenarios. NET MVC razor, but it is never called. js or index. Internet Explorer (up to version 8) used an alternate attachEvent method. close() that actually does what is expected and something that happens just fine in every browser that is NOT Chrome based? Mar 8, 2011 · Onclick is indeed javascript per default, but it's not bad practise and actually useful to include the javascript: prefix. Please guide. id or event. body in case the targetElement is not there There are some syntax errors that you might check for in your original code, but this does the trick (don't know what you originally try to solve though, this is a horrible way of adding Feb 22, 2013 · Can someone explain to me why this function call works in Firefox but not IE, and what needs to be done for it to work in IE. Internet Explorer 9 supports the proper addEventListener method. If not, an inline event may seem like they'd do the trick, but you're much better served preparing for a future that, though it may seem unlikely, is May 7, 2019 · Good reason to not put onclick attributes inside the HTML. Now you can use e. I've looked for some decent documentation regarding the IE application object, but can't seem to find a good source. So I updated the post to show more of my code. Mar 4, 2022 · The reason for this is not due to any meta data in VF page or any onclick stuffs in Javascript - it is because IE don't like the way of clicking on hidden input file tag. When I click on the image it shows that 'the function is undefined'. Mar 9, 2010 · The function won't fire by clicking on the checkbox for some reason, but the calling function works fine (if I copy the exact "onclick" attribute over to the label for the checkbox, it works fine). body in case the targetElement is not there There are some syntax errors that you might check for in your original code, but this does the trick (don't know what you originally try to solve though, this is a horrible way of adding Feb 5, 2005 · what's totally weird about this is that when i change 'onclick' to 'onmouseover', the script works in Internet Explorer too. The question is a matter of browser compatibility and necessity. Collapsible element, that is used to expand a body of text does I am working a project with reactJS as the main framework and using latest react hooks. I have something like this, which does not work: <script type="text/javascript"> function Nov 30, 2012 · A function can be quite long, and defining it singularly to a single onclick, and not some independent variable that can be referenced later, might end up creating spaghetti code. Jun 4, 2012 · Code works across all major browsers, but firing a simple alert on click is not working. Jul 23, 2025 · In this article, we will see " Uncaught TypeError: document. Imports/Exports: Make sure all your imports and exports are correct. Some do. Understanding the onclick Event The essential of interactivity in web development, the onclick event triggers a JavaScript function when a Aug 13, 2013 · I even tried document. Any ideas? Programming & Development web-development , question 4 148 April 18, 2011 Jan 3, 2022 · For example. May 22, 2017 · Now I am not a star really with Javascript, but i seem to encounter the all known problem with mobile devices and the onclick function. Apr 9, 2010 · Next, you can't add an option to a select when that option has already been in a select in IE-up-to-7 (even after cloning!) due to another bug (you get “Invalid argument”). It is not working for me with IE 11 on Windows 7 Enterprise. The following works fine in Firefox and Chrome, but IE 8 will not call the submit () method when the anchor link is clicked. Calling this function within the same file is not an issue at all, as mentioned above. Your removeEventListener 's argument is not a reference to the function object that was previously attached. Javascript is not throwing any errors. Aug 12, 2015 · Onload Javascript Function not working the way I need. Here is my code: The other significant difference, of course, is that onclick will always work, whereas addEventListener does not work in Internet Explorer before version 9. 1 day ago · Uncaught TypeError: Cannot set property 'onclick' of null onclick not workingsee below is my javascript, <script type="text/javascript"> document. Function not defined javascript onclick * Learn how to fix the 'function not defined' error in JavaScript onclick event handlers. Feb 10, 2010 · We’ll have to wait for lytebox to complete doing its thing, so we’ll perform the onclick from a setTimeout after the page has loaded. In this guide, we will explore common JavaScript issues encountered in Internet Explorer and how to resolve them effectively. Doing console. Also, if I firstly open the page that contains the link to click in another tab, via right click and 'Open In New Tab', then the link will also work. However it's not working in IE probably because there is a button inside an anchor tag, what I wanted to do is use an onClick Aug 24, 2023 · The “ onclick JavaScript not working ” issue is a common block that many developers encounter. Fiddle. style. All buttons on the page that respond to the onclick event stop wor Oct 9, 2014 · OnClick function is not working in IE 10, but fine in older versions Asked 10 years, 6 months ago Modified 10 years, 6 months ago Viewed 1k times Learn how to fix onclick js not working with 3 easy steps. Jun 11, 2014 · javascript function internet-explorer-8 onclick edited Jun 11, 2014 at 20:29 asked Jun 11, 2014 at 19:28 user2588440 Mar 1, 2013 · I need to do form validation in this function so i have used return in function Jan 15, 2016 · A way that it seems to work, would be like this I add the element using document. Order Matters: Remember that function expressions are not hoisted like function declarations. onclick=change; function change () { Mar 9, 2010 · The function won't fire by clicking on the checkbox for some reason, but the calling function works fine (if I copy the exact "onclick" attribute over to the label for the checkbox, it works fine). Provides solutions for resolving issues with the JavaScript method window. May 11, 2007 · Message Too Old, No Replies onClick not working in IE IE7 javascript onclick issue Jun 4, 2012 · Mostly all web developer must have faced this issue. The following should be an attempt to write a cross-browser addEvent function. Do you need to attach more than one event to an element? Will you in the future? Odds are, you will. Nov 12, 2021 · I am working on a project and i added an onlclick function in 3 elements in my code but none of them works because that element is not a button or an anchor tag i guess but i have to do something w Jan 11, 2017 · So, I think it may be related to the discussion here: Microsoft Edge: onclick event stops working?. NET) web application in Microsoft Edge. If the function or object is already in the list of event listeners for this target, the function or object is not added a second time. @Matthew: The onclick handler is just named poorly -- it handles the event of radio button selection whether the button is clicked, touched, or activated by hitting "enter" on a keyboard. Is there any extra piece of code that i need to add in there. Here is a Jan 28, 2013 · window. getElementsByClassName (). target. If I access the page by entering the url (or redirected by a buttonclick from an other page) the . Is there a way to execute the Nov 4, 2013 · These are not happening. Jan 17, 2017 · I was testing my existing code in different browsers and following code is working fine in IE 8,9, Firefox. A touch gesture is performed on the element. onmouseover = function() {this. javascript function to generate random trivias via array not working on my HTML Sep 11, 2018 · I have a strange issue which I can only replicate on Microsoft browsers (Edge and IE11 tested). click is not a function " error created while using click () method in JavaScript. Mar 1, 2017 · using onclick vs EventListeners. In this guide, we will discuss the possible reasons behind this issue and provide you with practical solutions to get your onclick JavaScript back on track. I want to handle F1-F12 keys using JavaScript and jQuery. Use . ---as of today, January 21, 2017, in today's Google Chrome update, the above function also does not work in Chrome. using 'onmouseup' (which is mechanically the same thing as 'onclick') does not work, while the handler 'onmousedown' does work. onclick=change; function change () { Oct 14, 2021 · Does onClick work on mobile devices? Yes it will work. Mainly because dirty inline javascript is being used and javascript: prefix makes it much easier to detect for maintenance. So does anyone have real, functional and proven method of closing a window using something like javascript:window. May 9, 2017 · @X. what I found in my case was the function name being called on onChange event was clashing somewhere. Trying to figure out why it works in chrome but not IE11. addEventListener( 'click', function( event ) { }. The following approach will have a one hop - On click - take the control to a handler method and handler method, based on the event object, can deduct the click event and corresponding object. Dec 17, 2009 · Notes: jQuery is being used as well. Sep 19, 2008 · Actually, as far as I know, dynamically created inline event-handlers DO work perfectly within Internet Explorer 8 when created with the x. getElementById ('auth'). createElement instead, and append it to the to a target element, or to the document. I have looked at examples and other quest Nov 4, 2013 · These are not happening. Sep 30, 2017 · as a part of my Django app, I have a small js code that works fine in Chrome, but I just noticed that it is not working in IE or Microsoft Edge. document. Nov 12, 2021 · I am working on a project and i added an onlclick function in 3 elements in my code but none of them works because that element is not a button or an anchor tag i guess but i have to do something w Apr 9, 2010 · Next, you can't add an option to a select when that option has already been in a select in IE-up-to-7 (even after cloning!) due to another bug (you get “Invalid argument”). js? Or is the webpack compiling it already to bundle. Learn how to fix the onclick not working JavaScript error in 3 easy steps. The ones that don’t work in IE work fine in Chrome and FF. Liu Thanks for trying. com These straightforward steps remove stumbling blocks and get your JavaScript running smoothly in Internet Explorer 11. There is no difference in the code between ones that work and ones that do not work. Feb 5, 2019 · Below, on logging out from the Main window, the child window opened under OpenWindowWithGet () does not get closed under IE 11. Aug 3, 2011 · 148 addEventListener is the proper DOM method to use for attaching event handlers.