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

  • Home
  • SEARCH
  • 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 6349179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:33:53+00:00 2026-05-24T21:33:53+00:00

Is it okay to have an HTML document embedded inside the body tag of

  • 0

Is it “okay” to have an HTML document embedded inside the body tag of another HTML document?

The reason why I want to do this is so that I can call a javascript body onload — I cannot do that in the main HTML document because the main HTML code is dynamically generated by a controller (Yii) that controls other pages and I do not want to edit it.

*By the way, I tried it and it seems to work fine now, but I just want to be sure that the page will not break in the future for whatever reason.

<html>
<head>
<body>    
    <html>
    <head>
        <script type="text/javascript>
        function somefunction(){
        }
        </script>
    </head>
    <body onload="javascript:somefunction()">    
    </body>
    </html>
</body>
</html>
  • 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-24T21:33:54+00:00Added an answer on May 24, 2026 at 9:33 pm

    If all you want to do is attach an onload event, you’re going about it the wrong way.

    All you have to do is add a script element that attaches an onload event:

    <script type="text/javascript">
    
      function somefunction()
      {
        ...do stuff...
      }
    
    
      document.body.onload = somefunction;
    
    </script>
    

    Alternatively, if you’ve appended your JS files at the bottom of the page, they will be able to interact with the DOM similarly to how onload works. The reason to use onload is only so that the elements defined within the web page have been added to the DOM by the time a function is executed. If your scripts are after your content, the elements will be in the DOM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, if I have a html document that looks a bit like this: <div
Okay, I have this program and I don't want more than one instance of
Okay, so I have an javascript function that retrieves some HTML... function updateQuestions(i){ var
Okay, this is driving me crazy right now. I want to have a border
Okay I have this RewriteRule which is supposed to redirect any request for the
Okay so I have the following Code which appends a string to another in
Okay, this is just a crazy idea I have. Stack Overflow looks very structured
Okay this is a real headscratcher. I have an application which calls a web
Okay, I have a page on and on this page I have an iframe.
Okay so on my homepage http://www.stat-me.com i have a link that when pressed activates

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.