473,721 Members | 1,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Denied - How to set document.domain when writing to new window

I am getting an Access denied error when I write to a new window. The
situation and code are outlined below. I am setting the domain in the
main window. The problem is that the window I am popping up never gets
it domain set, even though I have coded it to be the same as the main
window. I get an Access Denied errror.

Four different domains:
*localhost.myco mpany.com
*test.mycompany .com
*pilot.mycompan y.com
*mycompany.com

Page 1 on localhost.mycom pany.com has its domain set via script:
document.domain ="mycompany.com "; This is the main window

Page 2 - Written to the popup window below also is also set to the same
domain. Upon submit, Page to calls page 3 which is name lookup
servlet. Page 3 returns the value to Page 1 (main window).

<script type="text/javascript">
winstr += '<html><head><t itle>my App<\/title>';
winstr += '<script
type="text\/javascript">doc ument.domain=\' mycompany.com\' <\/script>';
winstr += '<\/head>';
winstr += '<body>';
winstr += '<form name="myForm" method="get" action="default .do">';
winstr += '<div class="textbold ">Last Name:<\/div>';
winstr += '<input type="text" name="searchFil ter" id="searchFilte r"
size="26" \/>';
winstr += '<input type="submit" value="Search" \/><\/div>';
winstr += '<\/form>';
winstr += '<\/body>';
winstr += '<\/html>';
var w=220;
var h=120;
var winname='popWin dow';
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var winprops = 'height='+h+',w idth='+w+',top= '+wint+',left=' +winl +
',toolbar=no,st atus=no,menubar =no,scrollbars= no,resizable=no ';
if(win==null || win.closed)//only launch window if it doesn't already
exist
win = window.open("", winname, winprops);
win.focus();
windoc = win.document;
//win.document.do main='mycompany .com';
windoc.write(wi nstr);
windoc.close();
</script>

Mar 31 '06 #1
2 22648
johkar wrote:
I am getting an Access denied error when I write to a new window. The
situation and code are outlined below. I am setting the domain in the
main window. The problem is that the window I am popping up never gets
it domain set, even though I have coded it to be the same as the main
window. I get an Access Denied errror.
Of course. document.domain works if the second-level domain of both
resources is the same. Since a generated document has no second-level
domain, you cannot set its document.domain . That said, I do not think
you need to.
[...]
<script type="text/javascript">
winstr += '<html><head><t itle>my App<\/title>';
winstr += '<script
type="text\/javascript">doc ument.domain=\' mycompany.com\' <\/script>';
winstr += '<\/head>';
winstr += '<body>';
winstr += '<form name="myForm" method="get" action="default .do">';
winstr += '<div class="textbold ">Last Name:<\/div>';
winstr += '<input type="text" name="searchFil ter" id="searchFilte r"
size="26" \/>';
winstr += '<input type="submit" value="Search" \/><\/div>';
winstr += '<\/form>';
winstr += '<\/body>';
winstr += '<\/html>';
Eeek. Provided that `winstr' was declared before, consider

winstr += new Array(
'<html><head><t itle>my App<\/title>',
'<script type="text/javascript">',
'document.domai n="mycompany.co m";',
'<\/script>',
'<\/head>',
'<body>',
'<form name="myForm" action="default .do">',
'<div class="textbold ">Last Name:<\/div>',
'<input name="searchFil ter" id="searchFilte r" size="26">',
'<input type="submit" value="Search"> <\/div>',
'<\/form>',
'<\/body>',
'<\/html>'
).join("");

instead.
var w=220;
var h=120;
var winname='popWin dow';
Unnecessary.
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
Think about <URL:http://dorward.me.uk/tmp/fullscreen.jpeg >.
var winprops = 'height='+h+',w idth='+w+',top= '+wint+',left=' +winl +
',toolbar=no,st atus=no,menubar =no,scrollbars= no,resizable=no ';
if(win==null || win.closed)//only launch window if it doesn't already
exist
if (!win || win.closed)

BTW, source code should be posted so that it can be executed as-is, also
meaning that it should not break when word-wrapped. Such (long) inline
comments should be before-comments, not after-comments.
win = window.open("", winname, winprops);
win.focus();
IMO, you should wait with focusing until you have written the content.
And you should feature-test the focus() method before you call it.
windoc = win.document;
You should declare _all_ your identifiers.
//win.document.do main='mycompany .com';
See above.
windoc.write(wi nstr);
windoc.close();
</script>

PointedEars
Mar 31 '06 #2
Thank you for the feedback.

Mar 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
17336
by: Ravi | last post by:
I am posting this message after reading all the previous posts with the above subject. I have a SQL2K named instance running on a Windows 2K machine under Local system Account and it uses SQL Server authentication. This Server is on a domain by itself. Let us call this M1. I am connecting to this server from an XP machine usinng Enterprise Manager. Let us call this machine M2. Since the client and server are on differentt domains when I...
2
6086
by: Wang, Jay | last post by:
I try to open up a window with window.open in javascript. "domain.html" contains domain information 'domain.school.edu'. The "Access denied" problem happens when document.write is trying to put variable s into the new window. Sometimes, it writes successfully, while other times the popup error is "access denied". How to solve this problem? thanks ____________________________ function setup(){ var w =
2
2500
by: ENIZIN | last post by:
I am having an interesting problem where I am simply trying to put in country selection popup window on my site. When the user closes the window the popup should call the window.opener.location.reload(true) function and show the newly selected country. Well, when I try it from my MAC box I get an Access denied error but when I do it from my IIS box it works. Both environments are using the same exact function to open the popup. In fact...
0
5215
by: David Palau | last post by:
We have a internal company WinForms application that makes some calls out to a intranet web service (once at application start-up for some configuration info and then periodically during the life of the application for specific functional requests). We are getting System.Net.WebException with HTTP 401: Access Denied errors periodically when we are attempting some functional web service calls. However, immediately trying the web service...
0
1188
by: Matt | last post by:
Just create a web service and web site. First wsdl webservice and installed with website i am getting access denied error. Second tried web referance my service from website with VS and still getting access denied error. I am using window auth. This also happens when i use SQL connection. so far i have tried. 1. Configure IIS with anonymous access No luck. 2. used Credential access no luck. ColService.CollectService colsrv = new...
1
1020
by: Stephen | last post by:
Hi, What permission setting do I have to enable to allow an Excel spreadsheet to a folder on my webserver? I get "access denied" message when I try to write it onto a webserver I have imported Microsoft.Office.Interop.Exceland other classes Thanks, Stephen
2
1058
by: Tim Payne | last post by:
Hi, I have a site that works perfectly on my local machine and on a number of other servers, that uses forms authentication for the admin area. On a new server that I'm setting it up on, I get a 401 Access Denied .Net error when I try to access the protected folder. The rest of the .Net pages work fine and show up, it's just the forms authentication protected area. Does anyone have any odeas what could be causing this? Regards,
0
8834
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8727
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9365
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8002
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5973
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4748
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2569
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2127
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.