"Permissions denied" in IE 8 and 7 using jQuery

I am creating a jquery plugin. this works fine in chrome, Mozilla, and IE 9, but in IE 8/7 I get a Permission denied error in the line "$ ctxObj.control2.val (opt.topicDefaultText);"

IE console

Test.Plugin = function () { var $ctxObj = {}; var opt = {}; var initEvents = function() { $ctxObj.control2.val(opt.topicDefaultText); $ctxObj.control2.on('click', function (e) { somefunction(); }); $ctxObj.control1.on('click',function(){ anotherfunction(); }); }; return { init: function (options) { var defaultOptions = { control1: '#control1', control2: '#control2', topicDefaultText:'test' }; opt = $.extend({}, defaultOptions, options); $ctxObj.control1 = $(opt.control1); $ctxObj.control2 = $(opt.control2); initEvents(); } }; 

} ();

if I declare a variable for each control, as shown below:

var $ control1 = $ ('# control1');

var $ control2 = $ ('# control2');

and then using the code

  $control2.val(opt.topicDefaultText); $control2.on('click', function (e) { somefunction(); }); $control1.on('click',function(){ anotherfunction(); }); 

using the above code. I do not get any errors in IE, but, like in this plugin, I have so many controls, so I do not want to do this.

+4
source share
2 answers

Make sure that all properties of the object are set and you really have access to them.

0
source

IE has a big problem with jQuery. My IE9 always tells me to enable ActiveX controls when I test jQuery. Try telling IE users to enable ActiveX controls.

0
source

Source: https://habr.com/ru/post/1448074/


All Articles