Skip to main content
Inspiring
June 7, 2020
Question

Klammern funktionieren nicht

  • June 7, 2020
  • 1 reply
  • 796 views

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

 

 

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 7, 2020

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");

}

hds26846Author
Inspiring
June 7, 2020

danke !!

 

pop = window.open("land_"+x+"_seite_"+y+"_bt_1" , 'new', 'width ...........

 

klappt nicht

hds26846Author
Inspiring
June 8, 2020
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 !!