Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

JSError- microsoft jscript runtime error object doesn't support property or method 'addeventlistener'

Apr 22, 2012
Introduction: 

In this article I will explain how to solve problem of “microsoft jscript runtime error object doesn't support property or method 'addeventlistener'” during working with click events in JavaScript.

Description:

In Previous posts I explained how to integrate facebook login button in asp.net during implement that functionality I written functions like this to handle hyperlinks click events in JavaScript


document.getElementById('auth-loginlink').addEventListener('click', function() {
FB.login();
});
document.getElementById('auth-logoutlink').addEventListener('click', function() {
FB.logout(function() { window.location.reload(); });
After written above event handlers if I run application I got error like “microsoft jscript runtime error object doesn't support property or method 'addeventlistener'”.

After get this error I realized that 'addeventlistener' events working only in firefox not working in IE.

To solve this problem and make hyperlinks click functions will work in all browsers I used JQuery click events for that I added latest JQuery script file in header section of application that is

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
After that I changed click events of hyperlinks to like this


$("#auth-loginlink").click(function() { FB.login(); });
$("#auth-logoutlink").click(function() { FB.logout(function() { window.location.reload(); }); });
After change 'addeventlistener' events to JQuery click events then that works in all browsers. If you want live example check this post how to integrate facebook login button in asp.net. I hope it helps you to solve your problem.

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

chris said...

thank you so muck for posting this - your jquery solution is perfect!

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.