470,580 Members | 2,327 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,580 developers. It's quick & easy.

new window - can't read property

hello. I've code like this:

var x =window.open('http://localhost/canvas.html','myokno')
var w =x.width
Permission denied to get property Window.width
var w =x.innerWidth

Permission denied to get property Window.innerWidth
why i can get properties of new created window???
The second problem is much more important:
i want to get element which id is "canvas" and it is in new window so i do
like this:

var canvas = myokno.document.getElementById('canvas')
ReferenceError: myokno is not defined
var canvas = x.document.getElementById('canvas')
Permission denied to call method HTMLDocument.getElementById

so i start working on the problem and:
var can = x.document
can
[object HTMLDocument]
var can2 = can.getElementById('canvas')
Permission denied to call method HTMLDocument.getElementById

what i doing wrong?
Any help will be appreciated.
Sep 30 '05 #1
2 12704
Hi Grzegorz Slusarek,

Grzegorz Slusarek wrote:
hello. I've code like this:

var x =window.open('http://localhost/canvas.html','myokno')
var w =x.width
Permission denied to get property Window.width well, the popup window and the script which initiated it must be in the
same domain. (for eg). when you have a html file in "c:\sample.htm",
from which you popup "http://localhost/canvas.html", you cannot access
its properties. Its a security thing that browsers have implemented. So
copy the sample.htm to your localhost access it as
'http://localhost/sample.htm'.
var w =x.innerWidth

Permission denied to get property Window.innerWidth
why i can get properties of new created window???
The second problem is much more important:
i want to get element which id is "canvas" and it is in new window so i do
like this:

var canvas = myokno.document.getElementById('canvas')
ReferenceError: myokno is not defined wrong.... use 'x' as you have done below.
var canvas = x.document.getElementById('canvas')
Permission denied to call method HTMLDocument.getElementById

so i start working on the problem and:
var can = x.document
can
[object HTMLDocument]
var can2 = can.getElementById('canvas')
Permission denied to call method HTMLDocument.getElementById

what i doing wrong?
Any help will be appreciated.


-- Peroli Sivaprakasam

Sep 30 '05 #2
Grzegorz ¦lusarek a écrit :
hello. I've code like this:

var x =window.open('http://localhost/canvas.html','myokno')
var w =x.width
Permission denied to get property Window.width
var w =x.innerWidth

Permission denied to get property Window.innerWidth
why i can get properties of new created window???
Read the WindowObjectReference definition
http://developer.mozilla.org/en/docs...and_parameters
and then the last question of the FAQ
http://developer.mozilla.org/en/docs...indow.open#FAQ
The second problem is much more important:
i want to get element which id is "canvas" and it is in new window so i do
like this:

var canvas = myokno.document.getElementById('canvas')
ReferenceError: myokno is not defined
When you created the window, the returned value was not stored in a
variable with the identifier "myokno": that's what the error message is
saying. Without being able to examine your code, it's impossible to
comment more.
var canvas = x.document.getElementById('canvas')
Permission denied to call method HTMLDocument.getElementById

so i start working on the problem and:
var can = x.document
can
[object HTMLDocument]
var can2 = can.getElementById('canvas')
Permission denied to call method HTMLDocument.getElementById

what i doing wrong?
Any help will be appreciated.


There are examples and best practices at this page:

http://developer.mozilla.org/en/docs/DOM:window.open

Basically, you are trying to modify (or set or get) properties or call
methods from one window to another which do not share the same domain
name: you can't do that... there are security reasons for this.

Gérard
--
remove blah to email me
Oct 3 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Renuka | last post: by
2 posts views Thread by Randell D. | last post: by
3 posts views Thread by anonieko | last post: by
2 posts views Thread by Anita C | last post: by
6 posts views Thread by G Dean Blake | last post: by
26 posts views Thread by yb | last post: by
24 posts views Thread by Jeremy J Starcher | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.