[js] veranderen visibility button in child window

Pagina: 1
Acties:

  • Brakkie
  • Registratie: Maart 2001
  • Niet online
Ik heb het volgende stukje code geschreven.

code:
1
2
3
4
5
6
7
8
9
10
function PopWindow(page, board_title, board_action)
{
win=window.open(page,'win','width=760,height=310,menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=no,linkbar=no, top=100,left=100');
win.focus();

    if(board_action == 'insert')
    {
        win.document.getElementById('attach_button').style.visibility = "hidden";
    }
}


Het is dus de bedoeling dat afhankelijk van de board_action de button met id attach_button zichtbaar is of niet. Het If statement komt het scriptje voorbij alleen veranderd hij de visibility van de button niet. De volgende error krijg ik in phoenix.

code:
1
2
3
Error: win2.document.getElementById("attach_button") has no properties
Source File: http://www.djplace.nl/~bart/js/js.js
Line: 200


line 200 is:
win.document.getElementById('attach_button').style.visibility = "hidden";

Dis de button:

<input type='button' id='attach_button' value='Attach Document' class='forms' onclick="addattachment('{document_name}','{document_id}', this.form);">

[ Voor 13% gewijzigd door Brakkie op 15-05-2003 11:32 ]

Systeem | Strava


  • crisp
  • Registratie: Februari 2000
  • Laatst online: 09:16

crisp

Devver

Pixelated

Misschien slim om even te wachten tot de pagina in je popup volledig geladen is?

Intentionally left blank


  • Brakkie
  • Registratie: Maart 2001
  • Niet online
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function PopWindow(page, board_title, board_action)
{
win=window.open(page,'win','width=760,height=310,menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=no,linkbar=no, top=100,left=100');
win.focus();

    for(;;)
    {
        if(win.document.readyState == 'complete')
        {
            if(board_action == 'insert_message')
            {
                win.document.getElementById('attach_button').style.visibility = "hidden";
            }
            break;
        }
    }
}


Top! Bedankt.


Edit:

Shit, dit werkt dus alleen in IE. :'( Iemand een manier voor Mozilla?

[ Voor 16% gewijzigd door Brakkie op 15-05-2003 12:05 ]

Systeem | Strava


  • crisp
  • Registratie: Februari 2000
  • Laatst online: 09:16

crisp

Devver

Pixelated

brakkie schreef op 15 mei 2003 @ 12:04:
[...]
Top! Bedankt.


Edit:

Shit, dit werkt dus alleen in IE. :'( Iemand een manier voor Mozilla?
zo'n cpu-vretende loop lijkt me niet echt handig :o

ik zou het zo doen:

JavaScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var win = null;
function PopWindow(page, board_title, board_action) {

  win=window.open(page,'win','width=760,height=310,menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=no,linkbar=no, top=100,left=100');
  win.focus();

  if(board_action == 'insert') setTimeout('hide_button()', 100);

}

function hide_button() {

  if (win.document && win.document.getElementById('attach_button')) {

    win.document.getElementById('attach_button').style.visibility = 'hidden';

  } else {

    setTimeout('hide_button()', 100);

}


als alternatief zou je voor Moz-compliancy ook het volgende in je popup kunnen doen:

HTML:
1
<body onload="if (typeof document.readyState == 'undefined') document.readyState = 'complete';">

Intentionally left blank


  • Brakkie
  • Registratie: Maart 2001
  • Niet online
Met die set time out werkt het perfect in mozilla en IE. Bedankt. Ik moet geloofk nog een beetje wennen aan de manier van denken bij client side scripting. Aan dat laden van de pagina had ik dus echt niet gedacht :)

Systeem | Strava