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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:23:49+00:00 2026-05-30T16:23:49+00:00

Bear with me, I’ve new to Javascript. Here’s my parent script: var title =

  • 0

Bear with me, I’ve new to Javascript.

Here’s my parent script:

var title = document.title;
var url = window.location.href;
var popForm;

function get_elements() {
    formObject = popForm.document.forms["link_form"];
    formObject.elements["id_title"].value = title;
    formObject.elements["id_url"].value = url;
    }

function bookmark() {

    popForm = window.open("form.html","aWindow","height=500,width=400");
    popForm.window.onload=get_elements()

    }

And my child just look slike this:

Title:</br>     
<input id="id_title" type="text" name="title" maxlength="50" />
</p>
Description:</br>
<textarea id="id_descrip" rows="10" cols="40" name="descrip"></textarea>
</p>
Url: <input id="id_url" type="text" name="url" maxlength="100" />
</p>
<input type="submit" value="Submit" />

I’m trying to create a little ‘share’ bookmarklet but cannot pass the data from the parent document to the popup’s elements. The error in Chrome’s console is Uncaught TypeError: Cannot read property 'elements' of undefined

What am I missing?!

  • 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-30T16:23:51+00:00Added an answer on May 30, 2026 at 4:23 pm
    popForm.window.onload=get_elements();
    

    ^ This is executing get_elements, not assigning it to the onload event.

    popForm.window.onload=get_elements;
    

    ^ This is how you assign a function to the onload handler, but this is something you would do in the head of a document, not as you are trying to do.

    popForm = window.open("form.html","aWindow","height=500,width=400");
    popForm.window.onload = get_elements;
    

    ^ In this code you have a race condition. In some cases popForm.window will be loaded by the 1st line before the 2nd line is executed. The onload event will only fire once, so if you don’t assign the handler before it fires, the 2nd line useless. In other cases popForm.window will not even exist yet when the 2nd line executes, making it impossible to assign a function to the onload event handler.

    The normal method of handling this situation, if you have control over the contents within the child window, is to put this code inside the child:

    formObject = document.forms["link_form"];
    formObject.elements["id_title"].value = window.opener.title;
    formObject.elements["id_url"].value = window.opener.url;
    

    If you do not have control over the contents of the child window, you need to wait until the document within the iframe has fully loaded. There is no way to know this from the parent except to keep checking over and over. Use code like below.

    popForm = window.open("form.html","aWindow","height=500,width=400");
    function waitForChild() {
        if (! popForm.window ) setTimeout(waitForChild, 1000);
        else get_elements();
    }
    waitForChild();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to php so please bear with me here. Its a rough example
New guy here so bear with me. Ive got a basic XSL file that
Bear with me as I am new to obj-c but I have a UIScrollView
Bear in mind here, I am not an Access guru. I am proficient with
Bear with me, I'm new to NUnit. I come from the land of Rails,
Bear with me, this is possibly a very specific problem we've encountered here: We
Bear with me. I recently started implementing jquery at work. I created a new
Bear with me, I'm new to manipulating XML using jQuery. Say I have an
Please bear with me, I am new to Uniscribe so I hope this isn't
Bear with me—this might be a bit confusing! I have a javascript that adds

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.