online 1
gast (50)

/ Forum / Skripte(PHP,ASP,Perl...)

Skripte(PHP,ASP,Perl...)Skripte(PHP,ASP,Perl...)

Fragevon js_rulez vom 22.07.2019, 17:40 Options

von benutzer defenierte methode

hey! eine function wo ich selbst gemacht habe soll eine methode sein. zun beispiel var str="string"; var crypt=str.rot13; alert(crypt); wie geht das?


Antwort schreiben

Antwort 1 von kicia vom 23.07.2019, 07:36 Options

Ich würde es so machen:


var  str = new c_str();
str.setvalue("456");
str.setabc("789");
alert(str.getvalue() + "\r\n" + str.getabc());

//------------
function c_str()
{
  this.value = "xyz";
  this.abc = "123";
  this.getvalue = function () { return this.value; }
  this.setvalue = function (s) { this.value = s; }
  this.getabc = function () { return this.abc; }
  this.setabc = function (s) { this.abc = s; }
  //...
}

Antwort 2 von js_rulez vom 23.07.2019, 10:51 Options

cool! abba nicht so wie ich will. abba cool! kicia rulez!
gibt noch andre möglichkeit dabei?

Antwort 3 von kicia vom 23.07.2019, 15:21 Options

Ich glaube, ich verstehe nicht ganz, was gefragt ist.
Willst Du eine Methode zum String-Objekt hinzufügen?
Beispiel:

String.prototype.xyz = c_xyz;

var str = new String("123");

function c_xyz()
{
	   return "<h1>" + this.valueOf() + "</h1>";
}

alert(str.xyz());

Antwort 4 von js_rulez vom 23.07.2019, 16:29 Options

coole schaisse! du bist der master von supportnet!!!!!!! thx

Ähnliche Themen

Hinweis

Diese Frage ist schon etwas älter, Sie können daher nicht mehr auf sie antworten. Sollte Ihre Frage noch nicht gelöst sein, stellen Sie einfach eine neue Frage im Forum..

Neue Einträge

Version: supportware 1.9.150 / 10.06.2022, Startzeit:Thu Jan 8 21:07:44 2026