Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 288867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:51:19+00:00 2026-05-12T05:51:19+00:00

Hi not sure if this is possible or not but I want to programaticaly

  • 0

Hi not sure if this is possible or not but I want to programaticaly update the <body> tags to change the onload function in my zend framework application.

The App is using layouts so the body tag currently looks like this <body class=”trandra”>

However in one of my views I have a map from google being loaded and it needs the following in the body tag this particular view <body onload=”initialize()” onunload=”GUnload()”>

As you can understand I don’t want this to be hardcoded in my layout as this will cause all matter of nightmares with the different views.

How can this be done programaticaly, if at all it is possible? Im using the headScript functions to add the javascript so is there an equivalant for the body tag?

Thanks in advance…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:51:20+00:00Added an answer on May 12, 2026 at 5:51 am

    Approach one – Use a layout variable

    One idea would be the following:

    <body class="trandra" <?php echo $this->layout()->bodyScripts ?>>
    

    And in your view:

    <?php
       $this->layout->bodyScripts = 
           'onload="initialize()" onunload="GUnload()"';
    

    Approach two – Additional JS-file that adds event handlers

    Another approach, which is less obtrusive and doesn’t affect the HTML whatsoever is to add an additional JS-file in the view that requires the onload- and onunload-handlers. It could look something like this:

    <?php
       $this->headScript()->appendScript(
                             '/path/to/javascripts/loadGMaps.js');
    

    In your loadGMaps.js (using prototype)

    Event.observe(window, 'load', function onLoadHandler() {
        // Code for initializing Google maps here
    });
    
    Event.observe(window, 'unload', function onUnloadHandler() {
        // Code for unloading Google maps here
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, not sure if this is even possible, but I want to change the
I'm not sure if this is possible but I want to see objects created
I am not sure if this is possible, but I want to store an
I'm not even sure if this is possible, but I want to combine blind
I'm not sure if this is possible but I want to show a TextView
I'm not sure if this is possible but I want to count the number
I'm not sure if this is possible but I want to be able to
I'm not sure if this is possible but I want to use mod_rewrite like
Good day, I'm not sure if this is possible but I want to merge
I am not sure if this is possible but I want to iterate through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.