what's wrong??!?!?!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tin

    what's wrong??!?!?!


    <script language="Javas cript">
    <!--
    function apri (theURL,winName ,features){
    window.open (theURL,winName ,features);
    var a=null;
    oldwindow = window.self;
    oldwindow.opene r = window.self;
    oldwindow.close ();
    }
    -->
    </script>


    <A
    href=javascript :apri('../pagine_popup/page_to_load.ht ml','finestra1' ,'width=
    220,height=260' ,'scrollbars=no ')>start</a>


    i wanna close the old page ONLY when i click on the link which open a new
    page.
    What's wrong? please help me :)

    daniele


  • Lasse Reichstein Nielsen

    #2
    Re: what's wrong??!?!?!

    "tin" <pa2215@panserv ice.it> writes:
    [color=blue]
    > i wanna close the old page ONLY when i click on the link which open a new
    > page.
    > What's wrong? please help me :)[/color]

    You tell me! What *is* wrong?

    To get qualified help, you need to tell us:
    1) What are you doing (inluding which browser you are using).
    2) What you expect to happen.
    3) What really happens.

    You failed to provide the third piece of information, so we have to
    run it ourselves and see what happens. Since we don't know which browser
    you are using, we might not get the same error.

    What error message does your browser give? Mine said something about
    an unterminated string literal. That is usually because a string has
    been broken onto two lines.
    [color=blue]
    > <script language="Javas cript">
    > <!--
    > function apri (theURL,winName ,features){
    > window.open (theURL,winName ,features);
    > var a=null;
    > oldwindow = window.self;
    > oldwindow.opene r = window.self;
    > oldwindow.close ();
    > }
    > -->
    > </script>[/color]

    This script looks operable. A more correct version would be:

    <script type="text/javascript">
    function apri(theUrl,win Name,features) {
    window.open(the Url,winName,fea tures);
    window.opener = window;
    window.close();
    }
    </script>

    You should know that this script abuses a bug in IE that allows you to
    close a browser window that was not opened by the page. That is a bad
    thing to do, and can make users very angry. It might also get fixed in
    a later version of the browser.
    [color=blue]
    > <A
    > href=javascript :apri('../pagine_popup/page_to_load.ht ml','finestra1' ,'width=
    > 220,height=260' ,'scrollbars=no ')>start</a>[/color]

    This is incorrect HTML. Attributes containing anything except
    alphanumeric characters and a few select elements of punctuation
    *must* be quoted.

    You should also avoid using the javascript: pseudo protocol.
    <URL:http://jibbering.com/faq/#FAQ4_24>
    It has potential side effects that you avoid in *this* case, but it is
    a bad habit to get. Use the onclick attribute instead. Also notice
    that you pass four arguments to a function that only uses three.

    <a href="noJS.html "
    onclick="apri(' ../pagine_popup/page_to_load.ht ml','finestra1' ,
    'width=220,heig ht=260,scrollba rs=no,resizable =yes');">
    start</a>

    If you remove the scrollbars, you should *alway* make the window
    resizable. Otherwise, content might be placed outside the visible area
    with no way to get to it. Remember that you cannot control the font size
    of the users browser if he choses to override it.

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • tin

      #3
      Re: what's wrong??!?!?!

      my browser is IE5.5
      [color=blue]
      > 3) What really happens.[/color]
      two new pages appear because i used your code:

      <a href ="noJS.html"

      onclick="apri(' ../pagine_popup/page_to_load.ht ml','finestra1' ,'width=220,hei
      ght=260,resizab le=yes');">
      start</a>

      and the IE try to open two page: nojs.htm and page_to_load.ht ml but i need
      the one opened with the onclick
      the old page doesn't close because the link is placed on the center of a
      framed page. So i need to close all the frame. How can i do this?
      I didn't do the graphical job. That's why i didn't knew that it is a framed
      page.

      thanks


      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: what's wrong??!?!?!

        "tin" <pa2215@panserv ice.it> writes:
        [color=blue]
        > my browser is IE5.5
        >[color=green]
        > > 3) What really happens.[/color]
        > two new pages appear because i used your code:[/color]

        Ah, yes. If the closing of the window fails, that would be the effect.
        [color=blue]
        > <a href ="noJS.html"
        >
        > onclick="apri(' ../pagine_popup/page_to_load.ht ml','finestra1' ,'width=220,hei
        > ght=260,resizab le=yes');">[/color]

        To prevent the noJS.html file from opening (in which you explain why
        your page requires Javascript to work), you add "return false" to the
        end of the onclick attribute value. That cancels the click so the href
        isn't opened.
        [color=blue]
        > and the IE try to open two page: nojs.htm and page_to_load.ht ml but i need
        > the one opened with the onclick[/color]
        [color=blue]
        > the old page doesn't close because the link is placed on the center of a
        > framed page.[/color]

        That explains why it doesn't close.
        [color=blue]
        > So i need to close all the frame. How can i do this?[/color]

        Change the lines:
        window.opener = window;
        window.close();
        to
        top.opener=top;
        top.close();
        That should close the entire frameset.

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        • tin

          #5
          Re: what's wrong??!?!?!

          everithing is working
          thanks



          "Lasse Reichstein Nielsen" <lrn@hotpop.com > ha scritto nel messaggio
          news:ekxipgaj.f sf@hotpop.com.. .[color=blue]
          > "tin" <pa2215@panserv ice.it> writes:
          >[color=green]
          > > my browser is IE5.5[/color][/color]


          Comment

          • HikksNotAtHome

            #6
            Re: what's wrong??!?!?!

            In article <r81ippxi.fsf@h otpop.com>, Lasse Reichstein Nielsen <lrn@hotpop.com >
            writes:
            [color=blue]
            >You should know that this script abuses a bug in IE that allows you to
            >close a browser window that was not opened by the page. That is a bad
            >thing to do, and can make users very angry. It might also get fixed in
            >a later version of the browser.[/color]

            Contrary to beliefs, its not a bug that is limited to IE. It is very
            widespread, in many browsers, in some form or another. Whether its closing the
            window or closing an active tab in tabbed browsers.
            --
            Randy

            Comment

            Working...