open new window problem

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

    open new window problem

    Hi there,

    I have a problem with opening new windows with JS. If the webpage did not
    complete loading due to any reason a click on a link which is supposed to open a
    small new other window loads instead the home page. If the page completes
    loading the link is working perfect.

    Here is the code:
    <a href="#"
    onclick="open_c enter('/subapp_profiles/member-information.php ?id=00000028',4 75,500);return
    false;" onMouseOver="st atus='display profile'; return true;"
    onMouseOut="sta tus='';" title="display profile">link text</a>

    Does anybody know how to fix that?

    Thanx in advance,

    Merlin


  • Lee

    #2
    Re: open new window problem

    Merlin said:[color=blue]
    >
    >Hi there,
    >
    >I have a problem with opening new windows with JS. If the webpage did not
    >complete loading due to any reason a click on a link which is supposed to open a
    >small new other window loads instead the home page. If the page completes
    >loading the link is working perfect.
    >
    >Here is the code:
    ><a href="#"
    >onclick="open_ center('/subapp_profiles/member-information.php ?id=00000028',4 75,500);return
    >false;" onMouseOver="st atus='display profile'; return true;"
    >onMouseOut="st atus='';" title="display profile">link text</a>
    >
    >Does anybody know how to fix that?[/color]

    Define open_center() in the <head> section of your page, so it will
    exist before the link is available to be clicked.

    Comment

    • Merlin

      #3
      Re: open new window problem



      Lee wrote:
      [color=blue]
      > Merlin said:
      >[color=green]
      >>Hi there,
      >>
      >>I have a problem with opening new windows with JS. If the webpage did not
      >>complete loading due to any reason a click on a link which is supposed to open a
      >>small new other window loads instead the home page. If the page completes
      >>loading the link is working perfect.
      >>
      >>Here is the code:
      >><a href="#"
      >>onclick="open _center('/subapp_profiles/member-information.php ?id=00000028',4 75,500);return
      >>false;" onMouseOver="st atus='display profile'; return true;"
      >>onMouseOut="s tatus='';" title="display profile">link text</a>
      >>
      >>Does anybody know how to fix that?[/color]
      >
      >
      > Define open_center() in the <head> section of your page, so it will
      > exist before the link is available to be clicked.
      >[/color]

      the open_center() funciton is inside a .js file which is loaded in the header
      section of the page. So this should not be the problem. I guess it has to do
      something with the way the link is coded. Any other ideas?

      Thanx for any hint,

      Merlin

      Comment

      • Lee

        #4
        Re: open new window problem

        Merlin said:[color=blue]
        >
        >
        >
        >Lee wrote:
        >[color=green]
        >> Merlin said:
        >>[color=darkred]
        >>>Hi there,
        >>>
        >>>I have a problem with opening new windows with JS. If the webpage did not
        >>>complete loading due to any reason a click on a link which is supposed to open a
        >>>small new other window loads instead the home page. If the page completes
        >>>loading the link is working perfect.
        >>>
        >>>Here is the code:
        >>><a href="#"
        >>>onclick="ope n_center('/subapp_profiles/member-information.php ?id=00000028',4 75,500);return
        >>>false;" onMouseOver="st atus='display profile'; return true;"
        >>>onMouseOut=" status='';" title="display profile">link text</a>
        >>>
        >>>Does anybody know how to fix that?[/color]
        >>
        >>
        >> Define open_center() in the <head> section of your page, so it will
        >> exist before the link is available to be clicked.
        >>[/color]
        >
        >the open_center() funciton is inside a .js file which is loaded in the header
        >section of the page. So this should not be the problem.[/color]

        Not true. You can't be sure that a .js file is completely loaded
        when the body starts to load.

        Comment

        • Robert

          #5
          Re: open new window problem

          Merlin <news.groups@gm x.de> wrote in message news:<2n40hbFsu fpdU1@uni-berlin.de>...
          [color=blue]
          > <a href="#"
          > onclick="open_c enter('/subapp_profiles/member-information.php ?id=00000028',4 75,500);return
          > false;"[/color]

          Calls a function. What does the function do? Not documented.
          onMouseOver="st atus='display profile'; return true;"
          Sets a switch
          [color=blue]
          > onMouseOut="sta tus='';"[/color]
          Resets a switch

          title="display profile">link text</a>


          I do not believe that you have provided enough information.

          Could you provide a website?

          Could you provide more code?

          Could you write up a minimal web page with all the code and conrols
          and duplicate the problem?

          Robert

          Comment

          • Merlin

            #6
            Re: open new window problem



            Robert wrote:[color=blue]
            > Merlin <news.groups@gm x.de> wrote in message news:<2n40hbFsu fpdU1@uni-berlin.de>...
            >
            >[color=green]
            >><a href="#"
            >>onclick="open _center('/subapp_profiles/member-information.php ?id=00000028',4 75,500);return
            >>false;"[/color]
            >
            >
            > Calls a function. What does the function do? Not documented.
            > onMouseOver="st atus='display profile'; return true;"
            > Sets a switch
            >
            >[color=green]
            >>onMouseOut="s tatus='';"[/color]
            >
            > Resets a switch
            >
            > title="display profile">link text</a>
            >
            >
            > I do not believe that you have provided enough information.
            >
            > Could you provide a website?
            >
            > Could you provide more code?
            >
            > Could you write up a minimal web page with all the code and conrols
            > and duplicate the problem?
            >
            > Robert[/color]

            I did copy the code from the .js file into the header, but the same result.
            If the page did not finish loading due to some images or similar a click on the
            link takes the user to the home page instead of opening a new window.

            Here is the code for open_center();
            // opens a new window in the middle of the screen without buttons and bars
            //-------------------------------------------------------------------------------------------------------
            function open_center(url ,width_,height_ ,scrollbar,tool bar,menubar,jum p) {

            var H_Browserrand = 12;
            var V_Browserrand = 30;
            var H_Aufloesung = screen.availWid th;
            var V_Aufloesung = screen.availHei ght;
            var H_Fenstergr = H_Aufloesung-H_Browserrand;
            var V_Fenstergr = V_Aufloesung-V_Browserrand;

            Fensterbreite = width_;
            Fensterhoehe = height_;

            H_offset= (H_Fenstergr-Fensterbreite)/2;
            V_offset= (V_Fenstergr-Fensterhoehe)/2;

            if (V_Fenstergr < Fensterhoehe){ // maybe the client has a smaller resulution
            than the image?
            V_offset = 0;
            Fensterhoehe = V_Fenstergr;
            vlimit= V_Fenstergr;
            }
            else{
            vlimit = 0;
            }

            // if (popup) popup.close();
            var popup =
            window.open(url +'&vlimit='+vli mit+'#'+jump,'D etail','width=' +Fensterbreite+ ',height='+Fens terhoehe+',left ='+H_offset+',t op='+V_offset+' ,
            resizable=no,sc rollbars='+scro llbar+',toolbar ='+toolbar+',st atus=no,directo ries=no,menubar ='+menubar+',lo cation=no')
            popup.focus();
            return popup;
            };
            //-------------------------------------------------------------------------------------------------------

            The page in action can be viewed here (click on a picture to see the problem):
            Travel Report on Nice by bineba. When you think of the French Riviera you think of glamour and wealth, but I found that the Cote d'Azur has a lot to offer even to a traveller who is neither glamorous or rich.


            Thank you for any help,

            Merlin

            Comment

            • Robert

              #7
              Re: open new window problem

              Merlin <news.groups@gm x.de> wrote in message news:<2n6gquFth cq0U1@uni-berlin.de>...[color=blue]
              > Robert wrote:[color=green]
              > > Merlin <news.groups@gm x.de> wrote in message news:<2n40hbFsu fpdU1@uni-berlin.de>...[/color][/color]
              [color=blue]
              > Here is the code for open_center();
              > // opens a new window in the middle of the screen without buttons and bars
              > //-------------------------------------------------------------------------------------------------------
              > function open_center(url ,width_,height_ ,scrollbar,tool bar,menubar,jum p) {[/color]

              The function has seven parameters but you only pass it three. Here is
              a version of open_center that fills in the missing parameters.

              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
              <html>
              <head>
              <meta http-equiv="Content-Type" content="text/html;
              charset=windows-1252">
              <title>Invoke a popup</title>


              <script type="text/javascript">

              function open_center(url ,width_,height_ ,scrollbar,tool bar,menubar,jum p)
              {


              if( typeof scrollbar == "undefined" )
              { scrollbar = "yes";}

              if( typeof toolbar == "undefined" )
              { toolbar = "yes";}

              if( typeof menubar == "undefined" )
              { menubar = "yes";}

              if( typeof jump == "undefined" )
              { jump = " ";}

              alert("scrollba r = " + scrollbar +
              " toolbar = " + toolbar +
              " menubar = " + menubar +
              " jump = " + jump );


              var H_Browserrand = 12;
              var V_Browserrand = 30;
              var H_Aufloesung = screen.availWid th;
              var V_Aufloesung = screen.availHei ght;
              var H_Fenstergr = H_Aufloesung-H_Browserrand;
              var V_Fenstergr = V_Aufloesung-V_Browserrand;

              // You are settting glabal variables here.
              Fensterbreite = width_;
              Fensterhoehe = height_;

              H_offset= (H_Fenstergr-Fensterbreite)/2;
              V_offset= (V_Fenstergr-Fensterhoehe)/2;

              // maybe the client has a smaller resulution than the image?
              if (V_Fenstergr < Fensterhoehe){
              V_offset = 0;
              Fensterhoehe = V_Fenstergr;
              vlimit= V_Fenstergr;
              }
              else{
              vlimit = 0;
              }

              var popup =
              window.open(url +'&vlimit='+vli mit+'#'+jump,'D etail',
              'width='+Fenste rbreite+
              ',height='+Fens terhoehe+
              ',left='+H_offs et+
              ',top='+V_offse t+
              ', resizable=no,sc rollbars='+scro llbar+
              ',toolbar='+too lbar+
              ',status=no,dir ectories=no,men ubar='+menubar+ ',location=no')

              popup.focus();
              return popup;
              };

              </script>

              <BODY>
              <p>Let's see if we can pop something up...

              <a href="#"
              onclick=
              "open_center('h ttp://www.yahoo.com?' ,
              475,
              500); return false;"
              onMouseOver="st atus='display profile'; return true;"
              onMouseOut="sta tus='';" title="display profile">click here</a>

              </body>
              </html>

              You are setting two global variables. Did you want too? See my
              comment in the code.
              [color=blue]
              > The page in action can be viewed here (click on a picture to see the problem):
              > http://www.globosapiens.net/travel-i...Nice-1172.html
              >[/color]


              This is a nice and informative site. It is professionally done with a
              lot of thought put into it. You are best advised to contact the
              programming team who wrote the site and inquire why you are
              experiencing difficulties with the page.

              Robert

              Comment

              • Grant Wagner

                #8
                Re: open new window problem

                Lee wrote:
                [color=blue][color=green]
                > >the open_center() funciton is inside a .js file which is loaded in the header
                > >section of the page. So this should not be the problem.[/color]
                >
                > Not true. You can't be sure that a .js file is completely loaded
                > when the body starts to load.[/color]

                I would certainly hope you can be sure a .js file is completely loaded when the body starts to load. The only exception to this is to
                explicitly use the DEFER attribute on the <SCRIPT> tag, which does allow the browser to parse/execute the JavaScript anytime it likes.

                <url: http://www.w3.org/TR/html4/interact/....html#h-18.2.1 />

                defer [CI]
                When set, this boolean attribute provides a hint to the user agent that the script is not going to generate any document content (e.g.,
                no "document.write " in javascript) and thus, the user agent can continue parsing and rendering.

                Given that DEFER explicitly allows the user agent to continue parsing and rendering (the HTML), it follows that the default (non-DEFER)
                alternative is that the browser stops to parse/execute the JavaScript before continuing to parse the HTML.

                If you have an example of a user agent that does not load:

                <script type="text/javascript" src="one.js"></script>
                <script type="text/javascript" src="two.js"></script>
                <script type="text/javascript" src="three.js"> </script>

                reproducibly sequentially, I'd be interested in knowing which one it is. I'd also recommend you contact the vendor and suggest they
                correct this behavior.

                --
                Grant Wagner <gwagner@agrico reunited.com>
                comp.lang.javas cript FAQ - http://jibbering.com/faq

                Comment

                Working...