Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE Error with e.preventDefault

I apologise in advance if this has already been covered but I’m new to this, I have seen there are other similar posts but none of them have helped so I am thinking there might be another issue.

I have a modal popup and it works fine in Chrome but doesn’t work in IE. The problem appears to be with the line

{ e.preventDefault(); }

It gives the following error.

Error: Object doesn't support property or method 'preventDefault'

Like I said I am new to this and I’ve tried doing what it says in other logs by putting an if round it or just removing the line but with no luck so could anyone help me.

/* prevent default behaviour on click */
var e = this.browserEvent;
var tgt = this.triggeringElement;
/*e.preventDefault();*/
{ e.preventDefault(); }
/* Trigger JQuery UI dialog */
var horizontalPadding = 30;
var verticalPadding = 30;
$('<iframe id="modalDialog" src="' + $(tgt).attr("href") + '" />').dialog({
   title: "IC v RT",
   autoOpen: true,
   width: 1050,
   height: 700,
   modal: true,
   close: function(event, ui) {apex.event.trigger('#P28_AFTER_MODAL','select',''); $(this).remove();},
   overlay: {
       opacity: 0.5,
       background: "black"}
}).width(1050 - horizontalPadding).height(700 - verticalPadding);
return false;
like image 456
Andy Avatar asked Jul 17 '12 14:07

Andy


People also ask

Why e preventDefault () is used?

The preventDefault() method is used to prevent the browser from executing the default action of the selected element. It can prevent the user from processing the request by clicking the link. Parameters: It does not accept any parameter.

What is E in E preventDefault?

The e in e. preventDefault prevents the default action when a link is clicked, which is the page refreshing or changing. So it allows for behavior such as clicking on a link making a call to the database without a page refresh.

How do I stop event preventDefault?

We can solve this problem by using the stopPropagation() method because this will prevent the parent from accessing the event. Example 1: HTML.


2 Answers

event.preventDefault ? event.preventDefault() : event.returnValue = false;

from event.preventDefault() function not working in IE

like image 136
Jashwant Avatar answered Oct 02 '22 17:10

Jashwant


if(event.preventDefault) 
{
  event.preventDefault();
}
else
{
   event.returnValue = false;
}
like image 21
Roopali Rawat Avatar answered Oct 02 '22 15:10

Roopali Rawat