10

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;
Tiny
  • 27,221
  • 105
  • 339
  • 599
Andy
  • 101
  • 1
  • 1
  • 3
  • possible duplicate of [event.preventDefault() function not working in IE. ](http://stackoverflow.com/questions/1000597/event-preventdefault-function-not-working-in-ie) – Jashwant Jul 17 '12 at 14:13

2 Answers2

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

from event.preventDefault() function not working in IE

Community
  • 1
  • 1
Jashwant
  • 28,410
  • 16
  • 70
  • 105
  • new Event(event).preventDefault();
    'Event' is undefined

    new Event.preventDefault();
    'Event' is undefined

    if(event.preventDefault) event.preventDefault();
    Unable to get value of the property 'preventDefault': object is null or undefined

    event.preventDefault ? event.preventDefault() : event.returnValue = false;
    Unable to get value of the property 'preventDefault': object is null or undefined

    event.returnValue = false;
    Unable to set value of the property 'returnValue': object is null or undefined
    – Andy Jul 17 '12 at 15:52
5
if(event.preventDefault) 
{
  event.preventDefault();
}
else
{
   event.returnValue = false;
}
Spudley
  • 166,037
  • 39
  • 233
  • 307
Roopali Rawat
  • 96
  • 1
  • 5