468,765 Members | 1,747 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Obtaining a variable value

Hi gang. As with any other post, I am working on a project and have
gotten stuck. I am trying to obtain a variable value in the parent
webpage from an <iframe>. For instance:

Parent Page code
----------------
<html>
.... heading tags
<body>

<iframe name="testing" marginwidth="1" marginheight="1"
src="http://www.interneturl.com/webpage.php" height="160" width="300"
scrolling="no" border="0" frameborder="0">&nbsp;</iframe>

</body>
</html>
When I try to access a variable value in that <iframe> it gives me the
error:
"uncaught exception: Permission denied to get property
Window.variablename". Obviously the <iframe> contains code from a
webpage that is not in the local domain (ie a local file). Would this
be causing the problem? If so, is there a way to get around this? I
have tried accessing the variable value from the ways listed below:

testing.variablename *seems to work on local files*
testing.document.variablename
parent.frames['testing'].variablename
parent.frames['testing'].document.variablename
frames['testing'].variablename
frames['testing'].document.variablename

Any help that can be given will be greatly appreciated... thanks in
advance.

Dave

Jul 23 '05 #1
3 1521
In article <11*********************@g14g2000cwa.googlegroups. com>,
he******@yahoo.com enlightened us with...
When I try to access a variable value in that <iframe> it gives me the
error:
"uncaught exception: Permission denied to get property
Window.variablename". Obviously the <iframe> contains code from a
webpage that is not in the local domain (ie a local file). Would this
be causing the problem?
Yes.
You're only allowed to access documents from the same domain and protocol.
If so, is there a way to get around this?


No. Not with client-side javascript. (if there is, it's a security hack)
Can you imagine what unscrupulous people could do if it were allowed?

If both pages belong to you, use parameter passing via the URL or cookies.

--
--
~kaeli~
Santa's helpers are subordinate clauses.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
Thanks for your reply Kaeli. I guess I will have to rethink my plans
on how to get this variable value.

I do have another question for everyone. Is there anyway you can get
javascript to sync time with a national time server? Any examples are
welcomed.

Dave

Jul 23 '05 #3
In article <11**********************@o13g2000cwo.googlegroups .com>,
he******@yahoo.com enlightened us with...
Thanks for your reply Kaeli. I guess I will have to rethink my plans
on how to get this variable value.

What is the variable used for?
Is the page yours? You have a lot more options if it is.

Do you have a server-side scripting language, such as PHP, available? Server-
side languages can read in contents from a URL. Javascript can, too, but it
needs help. Check this out.
http://jibbering.com/2002/4/httprequest.html
I do have another question for everyone. Is there anyway you can get
javascript to sync time with a national time server?


Depends. You run into the same issue as your other problem -- javascript
talking to another server. With possibly the same solution (http request or
using server-side scripting).
Do they have a web service?

--
--
~kaeli~
I love God. It's His fanclub that I can't stand.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by __jakal__ | last post: by
3 posts views Thread by psujkov | last post: by
8 posts views Thread by The Cool Giraffe | last post: by
15 posts views Thread by kris | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.