ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 8th, 2004, 12:59 PM
tonywang tonywang is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 tonywang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
using window.opner in jscript problem

Hi, guys,
I got a weired problem when trying to use the window.opener object. I need to open a new window from a home page, and once I get into the new window(it's actually on another site), I need to get the url of the calling window(the window that opened the current window). I can use the window.opener.location.href to set a new url for the old window, for example
<script language="JavaScript">
<!--
function getURL()
{

if (window.opener) {
alert("This window was opened by another window.");
window.opener.location.href="www.yahoo.com";
window.close();
}
else{
alert("This window was not opened by any other windows.");
}
}
//-->
</script>

which does work. Now the weired thing is that, when I try to get the value of the old window's URL like that:
<script language="JavaScript">
<!--
function getURL()
{

if (window.opener) {
alert("This window was opened by another window.");
var myOpener = window.opener.location.href;
//doing something here with the myOpener
//
}
else{
alert("This window was not opened by any other windows.");
}
}
//-->
</script>
The program just won't work. Somebody got a feel on that? thanks in advance!
Tony

Reply With Quote
  #2  
Old July 8th, 2004, 01:03 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,048 selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 2 h 58 m 53 sec
Reputation Power: 135
What happens if you just use:

Code:
var myOpener = opener.location.href;


MK

Reply With Quote
  #3  
Old July 8th, 2004, 01:08 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,048 selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 2 h 58 m 53 sec
Reputation Power: 135
Actually, this works equally well:

Opener

Code:
<html>
<head>
<title>PopUp 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
Create popup window <a href="#" onClick="MM_openBrWindow('pop2.html','PopUp','width=250,hei  ght=250')">here</a> 
</body>
</html>


Popup

Code:
<html>
<head>
<title>PopUp 2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="Wrapper"></div>
<script language="JavaScript">Wrapper.innerHTML=opener.location;</script>
</body>
</html>


MK

Reply With Quote
  #4  
Old July 8th, 2004, 01:10 PM
tonywang tonywang is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 tonywang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
No, it still doesn't work. Thanks though!

Tony

Reply With Quote
  #5  
Old July 8th, 2004, 01:15 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,048 selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 2 h 58 m 53 sec
Reputation Power: 135
Yep - it won't work across domains by the looks of things. This appears to be "by design" in order to protect cross-frame security

MK

Reply With Quote
  #6  
Old July 8th, 2004, 01:22 PM
tonywang tonywang is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 tonywang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
[QUOTE=selwonk]Actually, this works equally well:

still not working, what could be the problem?
Tony

Reply With Quote
  #7  
Old July 8th, 2004, 01:24 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,048 selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 2 h 58 m 53 sec
Reputation Power: 135
Quote:
Originally Posted by selwonk
Yep - it won't work across domains by the looks of things. This appears to be "by design" in order to protect cross-frame security

MK

I don't think you can do it. You might try adding the URL to a field in the original page and then trying to read it?

MK

Reply With Quote
  #8  
Old July 8th, 2004, 01:30 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Jun 2004
Posts: 3,048 selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level)selwonk User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 2 h 58 m 53 sec
Reputation Power: 135
Quote:
Originally Posted by selwonk
I don't think you can do it. You might try adding the URL to a field in the original page and then trying to read it?

MK

Nope - cross-domain security appears to stop you doing this as well

MK

Reply With Quote
  #9  
Old July 8th, 2004, 02:28 PM
tonywang tonywang is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 tonywang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by selwonk
Nope - cross-domain security appears to stop you doing this as well

MK

Yeah, I think that is the case. Thanks a lot guys.
Tony

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > using window.opner in jscript problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT