Autor Beitrag
Wolle92
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Sa 11.10.08 22:11 
Hallo,

jaja, der Wolle is ausm Urlaub zurück und hat gleich nen Problem...
Und zwar bringt das onchange-Attribut mein Javascript zum Aufhängen:
ausblenden Quelltext
1:
document.getElementByName("building").onchange = changeCookieValue();					

Das funktionierte nicht, also habe ich testweise mal den aktuellen Wert von onchange auslesen wollen:
ausblenden Quelltext
1:
alert("onchange: " + document.getElementByName("building").onchange);					

Aber auch das hat mein Script zum Aufhängen gebracht, weder diese Meldung, noch eine darauf folgende Testmeldung "b" erschien...
Die Testmeldung "a" direkt davor wird aber noch ohne Probleme ausgeführt...

Zur Info:
Ich nutze Firefox und das ganze ist ein Greasemonkey Userscript...

_________________
1405006117752879898543142606244511569936384000000000.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: So 12.10.08 12:52 
okay, es muss getElementsByName heißen, aber irgendwie will das Select (welches übrigens direkt in HTML gecodet ist) trotzdem kein onchange annehmen...
und auch nicht ausgeben...

_________________
1405006117752879898543142606244511569936384000000000.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 12.10.08 15:55 
ausblenden Quelltext
1:
document.getElementsByName('building')[0].onchange = function() { }					

geht nicht?

Was sagt denn Firebug zu dem Thema?

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: So 12.10.08 16:48 
wie kriege ich firebug denn dazu, was du nem GM-Skript zu sagen?

_________________
1405006117752879898543142606244511569936384000000000.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 12.10.08 16:58 
Naja, wenn da ein Script-Fehler war dann meldet der sich normalerweise schon...
Alternativ macht sich console.log() auch immer ganz gut. Wenn man dem Objekte übergibt, kann man die auch gleich im DOM-Inspektor laden.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: So 12.10.08 17:04 
naja, wenn ich einfach die Konsole mitlaufen lasse, dann bekomme ich nix...

obwohl die Zeile direkt aufgerufen wird...

_________________
1405006117752879898543142606244511569936384000000000.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 12.10.08 17:17 
Zeig mal den ganzen Code bzw. zumindest das direkt drumrum... es müsste eigentlich gehen ;)

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: So 12.10.08 17:24 
das direkt darum ist atm alles auskommentiert...
und value zum Beispiel lässt sich auch abrufen...

_________________
1405006117752879898543142606244511569936384000000000.
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: So 12.10.08 22:13 
Lösung gefunden:
www.oreillynet.com/p...pitfalls.html?page=3
Da die Nummer zwei...

So funktionierts bei mir auch endlich...

Jetzt muss ich nur noch rausfinden, wie ich Cookies eine bestimmte Zeit lang speichern lassen kann, nicht nur bis ans ende der sitzung...
hat sich auch erledigt, GM_setValue und GM_getValue sind besser...

_________________
1405006117752879898543142606244511569936384000000000.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 12.10.08 22:42 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
function createCookie(name, value, days)
{
  if (days) 
  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}

function eraseCookie(name)
{
  createCookie(name, "", -1);
}


@dein Problem: Hättest du gleich gesagt, dass du keine Funktion sondern einen String der eine Funktion identifiziert einfügst, hätte ich dir das auch sagen können. Und eventuell auf unsafeWindow und die GM-Sandbox hingewiesen ;)

Userscripts sind immer so ne Sache. Da liegt aber eben oft auch das Problem ganz wo anders, deswegen auch meine wiederholten Fragen nach etwas Code ;)

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."