[RESOLVED] Run Javascript onload of Content Page-VBForums
Results 1 to 4 of 4

Thread: [RESOLVED] Run Javascript onload of Content Page

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,605

    Resolved [RESOLVED] Run Javascript onload of Content Page

    On a regular page I can do a:

    <body onload="SomeScript();">

    How do I do the same when using Master Pages and there is no Body?
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  2. #2
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,962

    Re: Run Javascript onload of Content Page

    Hey,

    I have not sure that I follow exactly what you are saying.

    What exactly are you trying to achieve?

    My preference would probably be to inject the necessary JavaScript into the page using this:

    http://msdn.microsoft.com/en-us/library/btf44dc9.aspx

    in the load event of the pages, when necessary.

    Gary

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,605

    Re: Run Javascript onload of Content Page

    I was trying to actually run the script to load a Bing Map when the page_load event fired. I found a way to do it:

    On the master page I put:

    Code:
    <script language=javascript>
        function mp_onload()
        {
          if(window.body_onload != null)
          window.body_onload();
        }
      </script>
    </head>
    <body onload="mp_onload();">
    Then on my content page I put:

    Code:
        <script type="text/javascript">
             var map = null;
    
             var SDO = new VELatLong(28.751666667, -82.0625);
                    
             function GetMap()
             {
                map = new VEMap('myMap');
                map.LoadMap(SDO, 14, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);
                                  
             }
             
             function body_onload()
             {
                GetMap();
             }
    
          </script>
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  4. #4
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: [RESOLVED] Run Javascript onload of Content Page

    No point doing it on page_load codebehind unless you want to configure it greatly, it's going to be part of the JS load anyways.

    If you want to add shapes and tiles, etc. to the map, then use

    Code:
    map = new VEMap('myMap');
    map.onLoadMap = MyMainMethod;
    map.LoadMap(SDO, 14, VEMapStyle.Road, false, VEMapMode.Mode2D, true, 1);
    Where MyMainMethod does all the shape creation and adding.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.