By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

new window - can't read property

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.