V
V
Vady852019-04-07 16:20:57
Internet Explorer
Vady85, 2019-04-07 16:20:57

How to pass value to parameter of overridden onclick method in IE?

Hello!
Here is the code:

var a = document.createElement('a');
a.style.cursor='pointer';
var siteUrl = 'www.vasya.pupkin';
a.onclick=function(url){
  winPopup = window.open(url, 'windowOloginka', 'width=1000,height=1000,location=no');
}

Initially, I did this: through the property of the a.url object, in onclick I wrote: window.open(this.url,...)
This works in all browsers, but not in IE - access is denied! Only the option that resulted above works, but without passing values ​​to the parameter. How to pass siteUrl to function(url)?
I tried to do this after the curly brace:
}(siteUrl)
As a result, it works instantly, and not on click.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vady85, 2019-04-07
@Vady85

Thanks, I already found a solution from here: javascript.ru/forum/dom-window/26645-createelement...
i.e. it should have been like this:

var a = document.createElement('a');
a.style.cursor='pointer';
var siteUrl = 'www.vasya.pupkin';
a.onclick=function(url){
  return function(){
    winPopup = window.open(url, 'windowOloginka', 'width=1000,height=1000,location=no');
  }
}(siteUrl);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question