Avatar billede humlebien Novice
23. juni 2000 - 13:41 Der er 3 kommentarer og
1 løsning

Kontrollér et vindue fra et andet

Jeg har en lille javascript-funktion, der åbner et NYT vindue. Hvordan kan jeg styrer det GAMLE vindue fra det NYE vindue ..(indviklet forklaring). Det der er mit mål, er at lave en refresh på det GAMLE vindues target:top

Jeg håber at der nogen der forstår mig :o)!!!!
Avatar billede limemedia Nybegynder
23. juni 2000 - 13:53 #1
Det tror jeg nok jeg har. - Jeg har fundet en manual til dig, der skriver om netop det og meget andet godt ;D

http://webreview.com/pub/98/11/06/feature/index5.html

hele serien ses på

http://webreview.com/wr/pub/98/11/06/feature/index.html

/ Lars
LJWeb.com
Avatar billede limemedia Nybegynder
23. juni 2000 - 13:54 #2
-QUOTE-

With frames in a frameset its fairly straight forward to access the parent frame or the child frame, all you need to do is remember the object hierarchy. For example, the following frameset:

<FRAMESET COS="50%,50%>
<FRAME SRC="one.htm" NAME="left">
<FRAME SRC="two.htm" NAME="right">
</FRAMESET>

Produces the following structure:


            Parent Frame
                  |
            +----+----+
            |        |
          one.htm  two.htm


To access the parent frame from one.htm, use simply use: alert(parent.location.href), which will highlight the location of the parent frame, and similarily, to perform the reverse alert(window.one.location.href) will highlight the location of the left frame from the parent frame, and alert(parent.two.location.href) will highlight the location of the right frame from the left frame.

Once you've established this simple object syntax, you can use it to read and write almost any property of any other window within the frameset.

However, when you've opened a new window, the window does not form part of a frameset -- therefore a new means of accessing the new window from the opener (i.e., the window that opens the new window) is required and vice versa.

Well, accessing the new window is straight forward enough, you just use the window name as shown in the previous example. Modern browsers also include a means of accessing the opener window. Funny enough, by providing an opener property, e.g., window.opener, which will reference the window, if any, that opened the current window. For example alert(window.opener.location.href) will highlight the location of the current window's opener.

Unfortunately, the opener property was not made available in older browsers -- it was introduced in Nav3 -- but, we are able to create our own window properties/variables at any time:

<SCRIPT LANGUAGE="JavaScript">
<!--
myWindow10 = window.open('blank.htm','myExample10','width=200,height=200');
if (newWindow10.opener == null)
    newWindow10.opener = self;
//-->
</SCRIPT>

Avatar billede humlebien Novice
23. juni 2000 - 15:15 #3
Tak
Avatar billede stigc Nybegynder
15. august 2000 - 11:34 #4
Det er pæcis noget af det jeg søger. Men kan alle vinduer snakke sammen hvis de kender hinandens navne, eller kan man kun snakke sammen med et popup vindue?
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester