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
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. |
|||
|
|||
1 comments :
thank you so muck for posting this - your jquery solution is perfect!
Note: Only a member of this blog may post a comment.