Check properties of one window from another?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Check properties of one window from another?

Post by uberpolak »

I'm trying to use a popup window (yes I hate them too, but the way I'm doing what I'm doing it's necessary) to determine the parent.location of the window it spawned from, does anybody know how I can do this? I'm not very good with JavaScript.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Hi.

In the pop-up window add this code..

Code: Select all

<script language="JavaScript">

my_parent=window.opener.location;

</script>
That should do the trick I think.
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

thanks

Post by uberpolak »

That's the right object, thanks for your help, one more question though. Is there a way in Javascript to check for only part of a string, kind of like strstr() in PHP?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Yep.. I normally use this code to check for something within a piece of text..

Code: Select all

<script language="JavaScript">

this_text="check_for_BOB_in_this_text";

check_for="BOB";

if (this_text.indexOf(check_for)<0)
&#123;
// Nothing has been found
&#125;
else
&#123;
// It has been found so do something here
&#125;

</script>


Hope this helps.
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Excellent

Post by uberpolak »

That's just what I needed, thanks!
Post Reply