Autor Beitrag
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 10.06.09 09:49 
Tach,

nachdem ich hier schonmal ein ähnliches Problem hatte nun das:

index.html
ausblenden volle Höhe 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:
30:
31:
32:
33:
34:
35:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<script type="text/javascript">

function popiframe (handle) {
document.getElementById('zielframe').style.display = 'block';
window.frames['zielframe'].document.getElementById('search').focus();
//document.getElementById('zielframe').contentWindow.document.getElementById('search').focus();
}

/*
function setStartupFocus () {
e = document.getElementsByTagName('iframe');
for (i=0; i<e.length; i++) {
  if (e[i].style.display == 'block') {
    e[i].contentWindow.document.getElementById('search').focus();
    }
  }
}
window.onload = setStartupFocus;
*/

</script>

<title>none</title>
</head>

<body>
<button id="knopf" onclick="popiframe(this);">Hui</button>
<iframe id="zielframe" src="zielframe.html" style="display: none;"></iframe>
</body>

</html>


zielframe.html
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:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<script type="text/javascript">

/*
function setStartupFocus () {
document.getElementById('search').focus();
}
window.onload = setStartupFocus;
*/

</script>

<title>none</title>
</head>

<body>
<p>
<input type="text" id="search" />
</p>
</body>

</html>


Ein Iframe erscheint per display:none auf display:block und das Input darin soll den Focus bekommen.

So wie ihr es jetzt da seht funktioniert es im IE, aber im FF nicht. Die auskommentierten Zeilen hab ich schon als Alternativen versucht.

Interessant ist, dass bei gleich von Anfang an gezeigtem Iframe (style="display: block;") es in beiden Browsern funktioniert. (Ein Indiz für was? :gruebel: )

Jemand eine Idee?

Danke schonmal,
mfG,
WeBBy

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 10.06.09 14:51 
Was sagt die JS-Fehlerkonsole bzw. Firebug zu deiner Page?

Irgendwelche Meldungen?

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Horschdware
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 744
Erhaltene Danke: 54

Win XP Pro, Win 7 Pro x64
Delphi 7, Delphi XE, C++ Builder 5, SAP R/3
BeitragVerfasst: Mi 10.06.09 15:09 
Interessant ist,dass das hier bei zweimaligem Drücken des Buttons im FF zu einem richtigen Focus führt. Aber man muss dumemrweise zwei mal klicken
ausblenden Quelltext
1:
2:
3:
4:
5:
function popiframe (handle) {
  document.getElementById('zielframe').style.display = 'block';
  frames[0].document.getElementById('search').focus();

}



Edit:

Folgende Lösung ist zwar ein wenig doof, funktioniert aber ;-)

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
function popiframe (handle) {
  document.getElementById('zielframe').style.display = 'block';
  frames[0].document.getElementById('search').focus();

   window.setTimeout("setThatFocus()", 100);
}

function setThatFocus() {
  frames[0].document.getElementById('search').focus();
}

_________________
Delphi: XE - OS: Windows 7 Professional x64
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 10.06.09 22:37 
Tach,

user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
Was sagt die JS-Fehlerkonsole bzw. Firebug zu deiner Page?
Irgendwelche Meldungen?

Konsole keine und Firebug kannte ich bis jetzt nicht, hab allerdings nach diesem Tutorial auch nichts weiter rausbekommen. Vielleicht blick ich's auch einfach nicht...

user profile iconHorschdware hat folgendes geschrieben Zum zitierten Posting springen:
Interessant ist,dass das hier bei zweimaligem Drücken des Buttons im FF zu einem richtigen Focus führt. Aber man muss dumemrweise zwei mal klicken

Ja, sorry, das hab ich noch vergessen zu erwähnen: diesen Workaround wollte ich mit der neuen Lösung umgehen. :wink:

(Dass es ab den zweiten Mal Klicken funktioniert hab ich beim Frustabbau an der Maus gleich gemerkt, hehe...)

MfG,
WeBBy

_________________
Steht der Bauer im Gemüse, hat er später grüne Füße.