Copy link to clipboard
Copied
die klammern funktionieren nicht
x = 1;//land
y = 1;//seite
land_1_seite_1_bt_1 = "https://de.wikipedia.org/wiki/Schottland";//seite
this[["land_"+x]+["_seite_"+y]+"_bt_1"].on("click", anzeige_web_1_1);
function anzeige_web_1_1(evt) {
//pop = window.open(land_1_seite_1_bt_1, 'new',........);
pop = window.open([["land_" + x ] + ["_seite_" + y] + "_bt_1"] , 'new', .....);
pop.focus();
}
pop = window.open([["land_" + x ] + ["_seite_" + y] + "_bt_1"]
es kommt fehler 127.0.0.1:8090/land_1_seite_1_bt_1
Copy link to clipboard
Copied
you can't have an object named "https:// etc so
this["https:// etc ]
doesn't make sense.
if you have something reasonable like:
var xvar = 1;
var yvar = 1;
var urlVar = "https:// etc
and you had an object named land_1_seite_1_bt_1, you could use:
this[ "land_"+xvar+"_seite_"+yvar+"_bt_1"].on("click", anzeige_web_1_1);
function anzeige_web_1_1(evt){
pop = window.open(urlVar);
pop.focus();
}
and if you wanted to use xvar and/or yvar in anzeige_web_1_1 to control the url opened, they wouldn't need brackets because the url is a string, not an object:
function anzeige_web_1_1(evt){
window.open("https://www.some_partial_domain_name_"+xvar+"_more_domain_name_"+yvar+"_final_part.html");
}
Copy link to clipboard
Copied
danke !!
pop = window.open("land_"+x+"_seite_"+y+"_bt_1" , 'new', 'width ...........
klappt nicht
Copy link to clipboard
Copied
x = 1;//land
y = 1;//seite
land_1_seite_1_bt_1 = "https://de.wikipedia.org/wiki/Schottland";//seite
alert("land_"+x+"_seite_"+y+"_bt_1"];
//es soll https://de.wikipedia.org/wiki/Schottland angezeigt werden !
//es wird aber land_1_seite_1_bt_1 angezeigt !!
Copy link to clipboard
Copied
if you're trying to coerce a string variable, you'll need to reference the timeline where it's defined. for example,
var _this = this; // timeline variable _this stores the timeline that contains:
var land_1_seite_1_bt_1 = "https:// etc...;
var x =1;
var y = 1;
this.btn.on("click", anzeige_web_1_1);
function anzeige_web_1_1(evt){
var pop = window.open(_this["land_"+x+"_seite_"+y+"_bt_1"]);
// to test: alert(_this["land_"+x+"_seite_"+y+"_bt_1"]);
}
///////////////////////////////////////////////////////
or
// no need to define a _this variable because the timeline (this) reference is passed in function call below*
var land_1_seite_1_bt_1 = "https:// etc...;
var x =1;
var y = 1;
this.btn.on("click", anzeige_web_1_1.bind(this)); // *current timeline passed to anzeige_web_1_1 in bind(this)
function anzeige_web_1_1(evt){
var pop = window.open(_this["land_"+x+"_seite_"+y+"_bt_1"]);
// to test: alert(_this["land_"+x+"_seite_"+y+"_bt_1"]);
}
Copy link to clipboard
Copied
//funktioniert leider nicht !!!!!!!
//?????????
var land_1_seite_1_bt_1 = "https:de.wikipedia.org/wiki/Schottland";
var x =1;
var y = 1;
alert(_this["land_"+x+"_seite_"+y+"_bt_1"]);
Copy link to clipboard
Copied
ich komme nicht weiter !
was mache ich falsch ?????
danke vorab
Copy link to clipboard
Copied
where is _this defined? (ie, use "this" unless you explicitly define "_this" somewhere.)