<body onload="alert('Hello');"> does not work! Why?

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

    <body onload="alert('Hello');"> does not work! Why?

    Hi everyone,
    Has someone out there experienced the same problem? What i wanted to do is
    to display a popup window (modal) upon the loading of a webpage. Here is my
    code sample (in html view):
    <HTML>
    <HEAD>
    ....
    </HEAD>
    <BODY onload="ShowPop Up();" MS_POSITIONING= "GridLayout ">
    ....
    ....
    </BODY>
    </HTML>
    Where ShowPopUp() is a JavaScript function to display the popup window.
    However it does not get called. When I replaced the function with just a
    simple alert('Hello') function, still nothing is displayed at load up.
    However, crazy enough, I got it to work on some of the pages though.?????
    Is there anything that is missing or shouldn't be there?
    Please help me...
    Calvin
  • Patrick.O.Ige

    #2
    Re: &lt;body onload=&quot;al ert('Hello');&q uot;&gt; does not work! Why?

    Try using :-RegisterStartup Script Method

    Check sample at:-

    or
    ITProToday.com is a leading online source of news, analysis and how-to's about the information technology industry.



    Hope that helps
    Patrick

    "Calvin KD" <CalvinKD@discu ssions.microsof t.com> wrote in message
    news:896F67CD-F5A7-4ACC-8E93-A509CFB67D1A@mi crosoft.com...[color=blue]
    > Hi everyone,
    > Has someone out there experienced the same problem? What i wanted to do is
    > to display a popup window (modal) upon the loading of a webpage. Here is[/color]
    my[color=blue]
    > code sample (in html view):
    > <HTML>
    > <HEAD>
    > ...
    > </HEAD>
    > <BODY onload="ShowPop Up();" MS_POSITIONING= "GridLayout ">
    > ...
    > ...
    > </BODY>
    > </HTML>
    > Where ShowPopUp() is a JavaScript function to display the popup window.
    > However it does not get called. When I replaced the function with just a
    > simple alert('Hello') function, still nothing is displayed at load up.
    > However, crazy enough, I got it to work on some of the pages though.?????
    > Is there anything that is missing or shouldn't be there?
    > Please help me...
    > Calvin[/color]


    Comment

    • Eliyahu Goldin

      #3
      Re: &lt;body onload=&quot;al ert('Hello');&q uot;&gt; does not work! Why?

      It looks ok. Do you have javascript enabled on that machine?

      Eliyahu

      "Calvin KD" <CalvinKD@discu ssions.microsof t.com> wrote in message
      news:896F67CD-F5A7-4ACC-8E93-A509CFB67D1A@mi crosoft.com...[color=blue]
      > Hi everyone,
      > Has someone out there experienced the same problem? What i wanted to do is
      > to display a popup window (modal) upon the loading of a webpage. Here is[/color]
      my[color=blue]
      > code sample (in html view):
      > <HTML>
      > <HEAD>
      > ...
      > </HEAD>
      > <BODY onload="ShowPop Up();" MS_POSITIONING= "GridLayout ">
      > ...
      > ...
      > </BODY>
      > </HTML>
      > Where ShowPopUp() is a JavaScript function to display the popup window.
      > However it does not get called. When I replaced the function with just a
      > simple alert('Hello') function, still nothing is displayed at load up.
      > However, crazy enough, I got it to work on some of the pages though.?????
      > Is there anything that is missing or shouldn't be there?
      > Please help me...
      > Calvin[/color]


      Comment

      • Kevin Spencer

        #4
        Re: &lt;body onload=&quot;al ert('Hello');&q uot;&gt; does not work! Why?

        Where have you defined the JavaScript function? When you use the body
        "onload" event to call a function, it must be declared in the head. The
        RegisterStartup Script() method puts the JavaScript code that should run when
        the page is loaded at the bottom of the form. This always works, as long as
        there are no references in the script to HTML elements below the script in
        the page. This is due to the fact that browsers don't always get all of the
        HTML for the page in one swell foop.

        --
        HTH,

        Kevin Spencer
        Microsoft MVP
        ..Net Developer
        Paranoia is just a state of mind.

        "Calvin KD" <CalvinKD@discu ssions.microsof t.com> wrote in message
        news:896F67CD-F5A7-4ACC-8E93-A509CFB67D1A@mi crosoft.com...[color=blue]
        > Hi everyone,
        > Has someone out there experienced the same problem? What i wanted to do is
        > to display a popup window (modal) upon the loading of a webpage. Here is
        > my
        > code sample (in html view):
        > <HTML>
        > <HEAD>
        > ...
        > </HEAD>
        > <BODY onload="ShowPop Up();" MS_POSITIONING= "GridLayout ">
        > ...
        > ...
        > </BODY>
        > </HTML>
        > Where ShowPopUp() is a JavaScript function to display the popup window.
        > However it does not get called. When I replaced the function with just a
        > simple alert('Hello') function, still nothing is displayed at load up.
        > However, crazy enough, I got it to work on some of the pages though.?????
        > Is there anything that is missing or shouldn't be there?
        > Please help me...
        > Calvin[/color]


        Comment

        • Calvin KD

          #5
          RE: &lt;body onload=&quot;al ert('Hello');&q uot;&gt; does not work! Why?

          Thank you so much for all your responses.
          My ShowPopUp() javascript function is declared in the header on the same
          page as where it's called. What really puzzled me was even the
          onload="alert(' Hello');" did not display the message at load up.
          What I really want to do is showing the popup (modal) window, which is a
          Search screen where the user selects a record. When the popup is closed, the
          selected ID is returned back to the parent window, put the returned ID in a
          hidden field then reload the page so that the rest of the details can be
          displayed on the screen.
          How easy is it to do this using the RegisterStartup Script facility?

          Thanks again,
          Calvin

          "Calvin KD" wrote:
          [color=blue]
          > Hi everyone,
          > Has someone out there experienced the same problem? What i wanted to do is
          > to display a popup window (modal) upon the loading of a webpage. Here is my
          > code sample (in html view):
          > <HTML>
          > <HEAD>
          > ...
          > </HEAD>
          > <BODY onload="ShowPop Up();" MS_POSITIONING= "GridLayout ">
          > ...
          > ...
          > </BODY>
          > </HTML>
          > Where ShowPopUp() is a JavaScript function to display the popup window.
          > However it does not get called. When I replaced the function with just a
          > simple alert('Hello') function, still nothing is displayed at load up.
          > However, crazy enough, I got it to work on some of the pages though.?????
          > Is there anything that is missing or shouldn't be there?
          > Please help me...
          > Calvin[/color]

          Comment

          • Patrick.O.Ige

            #6
            Re: &lt;body onload=&quot;al ert('Hello');&q uot;&gt; does not work! Why?

            Calvin.
            I posted some sample links in my earlier post how you could use it.
            If u still can't figure it out post your Js and will feed you back.
            Patrick


            "Calvin KD" <CalvinKD@discu ssions.microsof t.com> wrote in message
            news:AEB7A777-8A07-4710-9527-8E36BF664DAE@mi crosoft.com...[color=blue]
            > Thank you so much for all your responses.
            > My ShowPopUp() javascript function is declared in the header on the same
            > page as where it's called. What really puzzled me was even the
            > onload="alert(' Hello');" did not display the message at load up.
            > What I really want to do is showing the popup (modal) window, which is a
            > Search screen where the user selects a record. When the popup is closed,[/color]
            the[color=blue]
            > selected ID is returned back to the parent window, put the returned ID in[/color]
            a[color=blue]
            > hidden field then reload the page so that the rest of the details can be
            > displayed on the screen.
            > How easy is it to do this using the RegisterStartup Script facility?
            >
            > Thanks again,
            > Calvin
            >
            > "Calvin KD" wrote:
            >[color=green]
            > > Hi everyone,
            > > Has someone out there experienced the same problem? What i wanted to do[/color][/color]
            is[color=blue][color=green]
            > > to display a popup window (modal) upon the loading of a webpage. Here is[/color][/color]
            my[color=blue][color=green]
            > > code sample (in html view):
            > > <HTML>
            > > <HEAD>
            > > ...
            > > </HEAD>
            > > <BODY onload="ShowPop Up();" MS_POSITIONING= "GridLayout ">
            > > ...
            > > ...
            > > </BODY>
            > > </HTML>
            > > Where ShowPopUp() is a JavaScript function to display the popup window.
            > > However it does not get called. When I replaced the function with just a
            > > simple alert('Hello') function, still nothing is displayed at load up.
            > > However, crazy enough, I got it to work on some of the pages[/color][/color]
            though.?????[color=blue][color=green]
            > > Is there anything that is missing or shouldn't be there?
            > > Please help me...
            > > Calvin[/color][/color]


            Comment

            • Calvin KD

              #7
              Re: &lt;body onload=&quot;al ert('Hello');&q uot;&gt; does not work! Why?

              Thanks so much Patrick. I think I have some ideas as how to do it and I will
              give it a shot.
              Would you be kind enough to check out this post again next week in case I
              still have issues and may ask for your help?
              Thanks again,
              Calvin.

              "Patrick.O. Ige" wrote:
              [color=blue]
              > Calvin.
              > I posted some sample links in my earlier post how you could use it.
              > If u still can't figure it out post your Js and will feed you back.
              > Patrick
              >
              >
              > "Calvin KD" <CalvinKD@discu ssions.microsof t.com> wrote in message
              > news:AEB7A777-8A07-4710-9527-8E36BF664DAE@mi crosoft.com...[color=green]
              > > Thank you so much for all your responses.
              > > My ShowPopUp() javascript function is declared in the header on the same
              > > page as where it's called. What really puzzled me was even the
              > > onload="alert(' Hello');" did not display the message at load up.
              > > What I really want to do is showing the popup (modal) window, which is a
              > > Search screen where the user selects a record. When the popup is closed,[/color]
              > the[color=green]
              > > selected ID is returned back to the parent window, put the returned ID in[/color]
              > a[color=green]
              > > hidden field then reload the page so that the rest of the details can be
              > > displayed on the screen.
              > > How easy is it to do this using the RegisterStartup Script facility?
              > >
              > > Thanks again,
              > > Calvin
              > >
              > > "Calvin KD" wrote:
              > >[color=darkred]
              > > > Hi everyone,
              > > > Has someone out there experienced the same problem? What i wanted to do[/color][/color]
              > is[color=green][color=darkred]
              > > > to display a popup window (modal) upon the loading of a webpage. Here is[/color][/color]
              > my[color=green][color=darkred]
              > > > code sample (in html view):
              > > > <HTML>
              > > > <HEAD>
              > > > ...
              > > > </HEAD>
              > > > <BODY onload="ShowPop Up();" MS_POSITIONING= "GridLayout ">
              > > > ...
              > > > ...
              > > > </BODY>
              > > > </HTML>
              > > > Where ShowPopUp() is a JavaScript function to display the popup window.
              > > > However it does not get called. When I replaced the function with just a
              > > > simple alert('Hello') function, still nothing is displayed at load up.
              > > > However, crazy enough, I got it to work on some of the pages[/color][/color]
              > though.?????[color=green][color=darkred]
              > > > Is there anything that is missing or shouldn't be there?
              > > > Please help me...
              > > > Calvin[/color][/color]
              >
              >
              >[/color]

              Comment

              • Calvin KD

                #8
                Re: &lt;body onload=&quot;al ert('Hello');&q uot;&gt; does not work! Why?

                Thanks so much Patrick. I have managed to get it to work base on your ideas.
                So thanks again.
                Cheers.
                Calvin

                "Patrick.O. Ige" wrote:
                [color=blue]
                > Calvin.
                > I posted some sample links in my earlier post how you could use it.
                > If u still can't figure it out post your Js and will feed you back.
                > Patrick
                >
                >
                > "Calvin KD" <CalvinKD@discu ssions.microsof t.com> wrote in message
                > news:AEB7A777-8A07-4710-9527-8E36BF664DAE@mi crosoft.com...[color=green]
                > > Thank you so much for all your responses.
                > > My ShowPopUp() javascript function is declared in the header on the same
                > > page as where it's called. What really puzzled me was even the
                > > onload="alert(' Hello');" did not display the message at load up.
                > > What I really want to do is showing the popup (modal) window, which is a
                > > Search screen where the user selects a record. When the popup is closed,[/color]
                > the[color=green]
                > > selected ID is returned back to the parent window, put the returned ID in[/color]
                > a[color=green]
                > > hidden field then reload the page so that the rest of the details can be
                > > displayed on the screen.
                > > How easy is it to do this using the RegisterStartup Script facility?
                > >
                > > Thanks again,
                > > Calvin
                > >
                > > "Calvin KD" wrote:
                > >[color=darkred]
                > > > Hi everyone,
                > > > Has someone out there experienced the same problem? What i wanted to do[/color][/color]
                > is[color=green][color=darkred]
                > > > to display a popup window (modal) upon the loading of a webpage. Here is[/color][/color]
                > my[color=green][color=darkred]
                > > > code sample (in html view):
                > > > <HTML>
                > > > <HEAD>
                > > > ...
                > > > </HEAD>
                > > > <BODY onload="ShowPop Up();" MS_POSITIONING= "GridLayout ">
                > > > ...
                > > > ...
                > > > </BODY>
                > > > </HTML>
                > > > Where ShowPopUp() is a JavaScript function to display the popup window.
                > > > However it does not get called. When I replaced the function with just a
                > > > simple alert('Hello') function, still nothing is displayed at load up.
                > > > However, crazy enough, I got it to work on some of the pages[/color][/color]
                > though.?????[color=green][color=darkred]
                > > > Is there anything that is missing or shouldn't be there?
                > > > Please help me...
                > > > Calvin[/color][/color]
                >
                >
                >[/color]

                Comment

                Working...