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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:13:06+00:00 2026-05-30T04:13:06+00:00

I am trying to query elements in another window (different domain), opened from my

  • 0

I am trying to query elements in another window (different domain), opened from my site. For example, I might have a link like this:

<a href="#" onclick=openOtherWindow();>Click me</a>  

Which runs code like this:

function openOtherWindow() {
  var w = window.open("http://www.example.com/", "my_popup","height=500, width=800 left=20, top=40");
  console.log('Left:' + w.screenLeft);
  console.log('Num anchors: ' + w.document.anchors.length);
  console.log('Num images: ' + w.document.images.length);
  w.close();
}

The window opens, and the console shows:

Left: 20
Num anchors: 0
Num images: 0

(Yes, there are links and images). So, I figured maybe the window hadn’t actually loaded, so tried something like:

function openOtherWindow() {
  var w = window.open("http://www.example.com/", "my_popup","height=500, width=800 left=20, top=40");
  w.onload = function() {
    console.log('Left:' + w.screenLeft);
    console.log('Num anchors: ' + w.document.anchors.length);
    console.log('Num images: ' + w.document.images.length);
  }
  w.close();
}

And now I am getting nothing in the console. I tried other ways of seeing what’s going on (replace console.log() with alert()) but no go.

I think I have a fundamental misunderstanding of how to know when the other window is open and loaded. Can anyone de-confuse me?

  • 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-30T04:13:08+00:00Added an answer on May 30, 2026 at 4:13 am

    If the domain is different, you cannot access most (if not all) properties of the new window. This is called same-origin policy and it’s for security reasons.

    For example, imagine that you register on a website and they send you an activation code by mail. Out of “courtesy”, they provide a link to GMail, Hotmail, Yahoo Mail and maybe a few other popular email providers. If they could access the contents from the new window, they could easily read your password when you type it in.

    Further information:

    • Same origin policy for JavaScript – MDN

    • Same origin policy – Wikipedia

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

Sidebar

Related Questions

I am trying to build query in Play framework, I have select * from
Before trying to query the AD server I would like to check if it
I am trying to query the windows desktop search API using SQL. I have
I am trying to query an .xls spreadsheet with VBScript, but I have run
I am trying to query against an IList<string> property on one of my domain
I have as a result from a dynamic query a table with only one
I have been trying to use the query functionality of the ItemFileReadStore to filter
I am trying to make a query in hql. I have these beans: Bean1
I'm trying to construct a linq query that pulls all nodes that have a
I'm trying to make a Linq query that will retrieve a string value from

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.