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 1043025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:36:03+00:00 2026-05-16T15:36:03+00:00

I have a frame page…. <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Frameset//EN http://www.w3.org/TR/html4/frameset.dtd> <html>

  • 0

I have a frame page….

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" 
"http://www.w3.org/TR/html4/frameset.dtd">

<html>
  <head>
     <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
     <title>Main title</title>
    <script type="text/javascript" src="JS.js"></script>
  </head>
  <frameset rows="10%,90%" id="frameid" name="frameName">
     <frame src="FrameA.htm"     name="F_A">
     <frame src="FrameB.htm"     name="F_B">
  </frameset>
</html>

Here’s FrameA.htm; FrameB looks similar

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
     <script type="text/javascript" src="JS.js"></script>
     <title>Frame A Title</title>
   </head>

   <body onload="parent.ldfunc()" class="Resize" id="idA">
      Body of frame A 
  </body>
</html>

and finally a javascript JS.js

function ldfunc () {
  alert("window.self.name: " + window.self.name);
  alert("window.self.document.body.id: " + window.self.document.body.id);
}

Now here’s the rub…

1) If the onload clause in the body tag is parent.ldfunc() as it is above, ‘self’ seems to be the frame page, not page A or page B. I.e. Id is displayed as frameid.

2) If the onload clause is ldfunc() WITHOUT the parent, ‘self’ points at page A or page B as expected. I.e. id is displayed as idA or iadB.

In other words, self seems to follow the function location, not the page.

Why did I try this? I’m going to have several thousand pages that will be loaded in B by A and I thought I could eliminate the need to put the script in each of their headers.

Is there some way to make the script loaded by the frame page global and available to the other pages?

  • 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-16T15:36:04+00:00Added an answer on May 16, 2026 at 3:36 pm

    window inside that function is not dynamically referenced. The reference to window is created on the moment the function is declared and is thus always the window reference to where the function resides. This is called a closure, when you basically embed external references inside a function at declare time.

    You need to pass the context window as an argument upon calling the function.

    Put scripts inside the top frame/window.
    Call functions with:

    top.funcName();
    

    And pass context.

    top.funcName(window);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have one html page with frames. The left frame is simply a
If I have a frame embedded into a html page. The page connects through
I have a 2-frame HTML page: FrameA contains a list of links to various
I have html page with frame where I want to show some web pages/sites.
I have a HTML frame on my ASP.NET page which pionts to a static
i have a html page called main.html which have a frame frame1 and a
I have a frame control in a WPF app which has an HTML page
I have an HTML page. I have created a frame using background repeat function.
I have a Frame element displaying an html page in my WPF application, and
I have the following code in the top frame of a two frame page:

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.