Obtaining a variable value

H

hendedav

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
 
K

kaeli

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.

--
 
H

hendedav

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
 
K

kaeli

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?

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top