/    Sign up×
Community /Pin to ProfileBookmark

window.opener question…

I have a html page that will call a child window. The child window needs to pass values back to the parent. Anyway, the two windows do everything I expect with no problems.

I then took the parent window and produce it dynamically thru a perl script. I need to do this as some of the form fields need data that I have stored in files. As before, the “dynamically” produced window calls the child window but now the child window doesn’t have a value for the opener. What happened?

Any help or advice would be greatly appreciated.

Mike

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterNov 21.2005 — Use a JavaScript external file generated by Perl. After either the parent or child windows change location, their link is broken. You might also want to try IFRAMEs.
Copy linkTweet thisAlerts:
@Mike_BurdickauthorNov 21.2005 — Ultimater,

Not sure what you mean, I'll have to think about that for awhile.

Here's the javaScript error generated: [B]Error: uncaught exception: Permission denied to get property HTMLDocument.getElementById[/B]

Does this confirm what you suggest in the last post?

Thanks....

Mike
Copy linkTweet thisAlerts:
@UltimaterNov 21.2005 — Looks like one window is trying to access another window from another domain -- aka a cross domain javascript security error.

One way around this is to use Perl's LWP::UserAgent module.
Copy linkTweet thisAlerts:
@Mike_BurdickauthorNov 21.2005 — Ultimater,

I have the the child in a subdomain htdocs directory and call it like this subdomain.domain.com/file.htm. It get to the file okay as everythink will load but any function using opener will not.

Perl's LWP::UserAgent module - Could you elaborate a little more?

Thanks...

Mike
Copy linkTweet thisAlerts:
@UltimaterNov 21.2005 — Ultimater,

I have the the child in a subdomain htdocs directory and call it like this subdomain.domain.com/file.htm. It get to the file okay as everythink will load but any function using opener will not.[/QUOTE]

Subdomains don't count as the same domain and it will generate a security error.

http://aplustv.com/public_stuff/subdomaintest.html

And hence you get your error in Firefox's Console:

Error: uncaught exception: Permission denied to get property HTMLDocument.getElementById
[/quote]
Copy linkTweet thisAlerts:
@Mike_BurdickauthorNov 21.2005 — Ultimater,

I just put the file in the root directory and now it's working okay!

Maybe I left out some information that would have helped you...

I have the subdomain directory password protected using .htaccess. I didn't think it came into play since to get to the html file that calls the script one has to enter the password. All the other files are working okay. But...maybe this wasn't the problem... or was it? What do you think?

Thanks...

Mike
Copy linkTweet thisAlerts:
@UltimaterNov 21.2005 — Perl's module [url=http://search.cpan.org/~gaas/libwww-perl-5.803/lib/LWP/UserAgent.pm]LWP::UserAgent[/url] is used to make an HTTP Request from a website and return it's HTML back to Perl in a string -- in a sense a string import method. Then Perl can print the HTML and treat the page as though it is from the same domain because JavaScript never encounters a cross-domain security error. It is much easier to do this in PHP with the function [color=blue]file_get_contents[/color] if you know how to use PHP. In Perl you'd need to do all this:
<i>
</i>require LWP::UserAgent;
my $ua = LWP::UserAgent-&gt;new;$ua-&gt;timeout(10);$ua-&gt;env_proxy;
my $feedback="";
my $lookuplink="http://www.google.com";
my $response = $ua-&gt;get($lookuplink);
if ($response-&gt;is_success) {$feedback=$response-&gt;content;}

In PHP you don't even need to use any modules and it is simple as:
<i>
</i>$feedback=file_get_contents("http://www.google.com");
Copy linkTweet thisAlerts:
@Mike_BurdickauthorNov 21.2005 — Well...I guess you gave me the answer while I was typing away... ?

Thanks as usual...

(your pain in the side) :o Mike
×

Success!

Help @Mike_Burdick 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 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...