/    Sign up×
Community /Pin to ProfileBookmark

DOM of another window or URL

Question: Why is the result of this:

[CODE]
var main2 = ‘ ‘;
main2 = window.open(“http://www.google.com”, “main2”);
document.write(main2.location.href);
[/CODE]

this?:

[CODE]
about:blank
[/CODE]

I would think it should be:

[CODE]
http://www.google.com
[/CODE]

Furthermore, is there any simple way to grab the DOM by supplying a URL? I’m looking to turn the web into my database (with support for cookies) with Javascript or PHP but not with Perl, as described in this <a href=http://www.developer.com/lang/article.php/3495126>article</a>.

-Rob

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 02.2005 — you have gave the same name to the variable and to the name of the window (which are different things)

var main2 = window.open("http://www.google.com", "[COLOR=Red]doesntmatter[/COLOR]");

document.write(main2.location.href);
Copy linkTweet thisAlerts:
@robinhoodeauthorNov 02.2005 — Ok.. yet this:

var whatever = window.open("http://www.google.com");

document.write(whatever.location.href);

or this:

var whatever = window.open("http://www.google.com");

document.write(whatever.location);

still returns:

about:blank

I'm trying to extract info on a given web page (one which has cookies), from the web browser. This is just a start in that direction.
Copy linkTweet thisAlerts:
@KorNov 02.2005 — well, yes. If the two pages are from different domains, you can not reach them via javascript. But you can use AJAX to grab information from another page, if different domain.

http://en.wikipedia.org/wiki/AJAX
×

Success!

Help @robinhoode spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 7.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ,
analytics: Fullres
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: Anonymous,
tipped: article
amount: 1000 SATS,

tipper: Anonymous,
tipped: article
amount: 1000 SATS,

tipper: @Nanditha,
tipped: article
amount: 1000 SATS,
)...