SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    united states
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sharing global variables accross pages

    Hello

    I have an HTML page which loads another page inside an IFrame.
    Each of the two pages has its own javascript code.

    I would like to be able to define one global variable which will be accessed from functions in both scripts.
    The variable must be single. That means that if a script in one of the pages changes it, the change will be seen by the scripts in the other page.

    Is that possible?

    thanks in advance

  2. #2
    SitePoint Addict
    Join Date
    Nov 2003
    Location
    Malmoe, Sweden
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you define the variable (var MyVariable) in the "main page" you can access it with script from the "iframe page" with parent.MyVariable.

  3. #3
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or you could store the variables in a javascript include

  4. #4
    SitePoint Addict
    Join Date
    Nov 2003
    Location
    Malmoe, Sweden
    Posts
    265
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or use cookies... Or on the other hand... No...

  5. #5
    SitePoint Member
    Join Date
    Apr 2004
    Location
    Bavaria
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cookies will always work - even across pages!
    Except for the one visitor, who won't accept cookies.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •