473,856 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.domain problem

Hello,

So we have a webmaster who sets document.domain to some domain. After
that, we try to create and inject text inside an iframe by getting the
iframeID.conten tDocument (or iframeID.conten tWindow.documen t for
MSIE). This results in an 'access denied' issue in MSIE (No problem in
Mozilla). Note that if there is document.domain initialization before
this iframe creation/content injection, there is no problem and all
works well.

To get around this issue, we tried to avoid accessing the iframe
document. Instead we assigned all the content to be injected to
iframe.src.
iframe.src='jav ascript:documen t.write("Conten ts to be injected")

This actually worked and even if there is a document.domain
declaration, we were able to successfully create and inject contents
inside the iframe.

The problem with this was that the maximum URL length in MSIE is 2K
characters. The value of iframe.src cannot be more than that. In our
case, we were going to be injecting contents over 2K all the time.
To address this, we did a work-around like this -
window.frames[iframe.name]['contents'] = "content to be injected";
iframe.src = 'javascript:doc ument.write(win dow["contents"])';

When we do this, it again results in an 'access denied' issue in MSIE
when document.domain is set before creating the iframe. But when
document.domain is not set, this method works well (as is expected).

I think I have explained my problem here - I want to be able to inject
contents inside an iframe and at the same time, have it work when we
have assignments for document.domain (and other similar attributes)
before the iframe creation/injection.

Appreciate any good tips/advise.

Thanks

Nov 8 '08 #1
1 6518
ra************* ***@gmail.com wrote:
So we have a webmaster who sets document.domain to some domain. After
that, we try to create and inject text inside an iframe by getting the
iframeID.conten tDocument (or iframeID.conten tWindow.documen t for
MSIE). This results in an 'access denied' issue in MSIE (No problem in
Mozilla). Note that if there is document.domain initialization before
this iframe creation/content injection, there is no problem and all
works well.

To get around this issue, we tried to avoid accessing the iframe
document. Instead we assigned all the content to be injected to
iframe.src.
iframe.src='jav ascript:documen t.write("Conten ts to be injected")

This actually worked
It shouldn't. The `javascript:' proprietary URI scheme/pseudo-protocol is
intended to generate dynamic documents by evaluating a Program, of which the
result is the result of the last evaluated expression. Since
document.write( ) should not return anything, the result of the expression
and the program would be `undefined', and that should result in an empty
document if any.

So what is supposed to work is

iframe.src = "javascript:'Co ntents to be injected'";
and even if there is a document.domain declaration,
There is no such thing. Probably you mean an _assignment_ to that property.
we were able to successfully create and inject contents inside the iframe.
That should not be surprising as its domain is null or the empty string then.
The problem with this was that the maximum URL length in MSIE is 2K
characters.
The maximum *URL length* in Internet Explorer is 2083 *characters*.
2K would be 2048 (characters), which is the maximum path length instead.

<http://support.microso ft.com/kb/208427>
The value of iframe.src cannot be more than that. In our
case, we were going to be injecting contents over 2K all the time.
One wonders why you go on lengths with all this nonsense when you could
simply replace the iframe element with another one to achieve the same.
To address this, we did a work-around like this -
window.frames[iframe.name]['contents'] = "content to be injected";
Host objects should not be augmented, it is error-prone.
iframe.src = 'javascript:doc ument.write(win dow["contents"])';

When we do this, it again results in an 'access denied' issue in MSIE
when document.domain is set before creating the iframe. But when
document.domain is not set, this method works well (as is expected).
You should not expect it to work.
I think I have explained my problem here - I want to be able to inject
contents inside an iframe and at the same time, have it work when we
have assignments for document.domain (and other similar attributes)
before the iframe creation/injection.
Why? The whole thing looks bogus.
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Nov 8 '08 #2

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

Similar topics

1
1574
by: Rahul Chatterjee | last post by:
Hello all I have a web page which has 3 frames. The top and the left navigation frames are on a separate domain. The right display frame initially starts on the same domain as the other two frames but after the user clicks on a URL, he is redirected to another domain. In this new domain I am setting session variables and cookies. TO give a brief over view of our test environment and production environment
2
7600
by: Cindy Lee | last post by:
Can this be done in https? If the page I'm on is at 'www.abc.com' can I: document.domain='www.def.com' i get invalid argument if i do that? Is there anyway around this?
1
4108
by: writeson | last post by:
Hi all, I'm working on a project at the office that pulls together a bunch of our websites into a portal thing and adds a better search engine. We're also trying to accomadate newer browsers (Netscape 7.2, Firefox, Safari) and are having some problems. The websites run on different servers, all of which we control, so we are setting the document.domain = "ourdomain.com"; in some javascript on ever page. However, we're having problems....
2
22658
by: johkar | last post by:
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.mycompany.com *test.mycompany.com *pilot.mycompany.com
1
6510
by: jkeel | last post by:
Can't seem to figure this out ... I'm trying to do some cross-frame scripting and ... When I do an alert(document.domain) in the onload event of the body I get an empty alert box. Then when I try to set the document.domain I get an Invalid argument. Why am I getting nothing returned when I do the initial
1
2809
by: vegetablebeef | last post by:
I know cross domain stuff has been discussed here before but I could not find a answer to my issue. I am a designer that does "hunt and peck" coding so again please excuse my lack of technical savy. Anyway here is the issue. I was trying to load external pages from content.mydomain.com into pages on web.mydomain.com. (I can not put all the pages into one place because the cma that my company uses only lets me put the text of the master page...
1
1318
by: abcbook | last post by:
Can anyone explain a get around for this .js file I’m trying to create or tell me if there is one or what am I missing. I Do Not what to put the form Directly on the HTML Page. This .js file will reside on many pages. and I want to be able to quick change the content of the .js file and have all pages automatically update by simply changing the content of the .js file. I understand the use of document(‘ and document” The problem...
3
1660
by: Alejandro Rivero | last post by:
On 18 abr, 19:50, Thomas 'PointedEars' Lahn <PointedE...@web.de> wrote: I see. I was mislead due to some hints on the contrary, as well as my bad memory and the fact that actually it applies someway: if I set document.domain to a different value that the real one, some XHR in firefox stop working. I guess that this could qualify for a bug but I do not know if I am interesting on researching further; it could also be that...
0
9921
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
11065
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
10700
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10795
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7934
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
7098
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
5962
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4177
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.