Obtaining a variable value

Discussion in 'Javascript' started by hendedav@yahoo.com, Mar 20, 2005.

  1. Guest

    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
    , Mar 20, 2005
    #1
    1. Advertising

  2. kaeli Guest

    In article <>,
    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
    kaeli, Mar 21, 2005
    #2
    1. Advertising

  3. Guest

    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
    , Mar 21, 2005
    #3
  4. kaeli Guest

    In article <>,
    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
    kaeli, Mar 22, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. david
    Replies:
    7
    Views:
    11,638
    Ricardo Dominguez
    Oct 10, 2012
  2. Replies:
    3
    Views:
    339
    Roedy Green
    Oct 19, 2005
  3. Replies:
    4
    Views:
    306
    Rod Pemberton
    Mar 13, 2006
  4. Roger Withnell
    Replies:
    9
    Views:
    305
    Aaron Bertrand - MVP
    Dec 2, 2003
  5. William Johnston

    obtaining sender value from document

    William Johnston, Apr 17, 2008, in forum: Javascript
    Replies:
    2
    Views:
    91
    Evertjan.
    Apr 17, 2008
Loading...

Share This Page