SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2001
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to access javascript variable on another page ?

    For example I have a javascript on one of my pages (page.html) that writes out as given below.
    Is there any way I can access the variable "gotoURL" in the "content.html" from the Javascript block in the "page.html" and change it's value ?

    HTML Page 1 (page.html)
    -------------
    <SCRIPT LANGUAGE="JavaScript">
    document.write ("<IFRAME src='/content.html' WIDTH='468' HEIGHT='60'>");
    doucment.write ("</IFRAME>");
    </SCRIPT>

    HTML Page 2 (content.html)
    -------------

    <html>
    <head>
    <title>Banner</title>

    <SCRIPT LANGUAGE="JavaScript">
    var gotoUrl = "http://www.mydomain.com";
    </SCRIPT>

    <script>
    function linkUrl()
    {
    var homewindow = window.open(gotoUrl);
    }
    </script>

    </head>

    <body>
    <a href="javascript:linkUrl()">
    <img src="/images/468x60.gif" name="banner" border="0">
    </a>
    </body>
    </html>

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi ipromote,

    You could try something like this:

    <iframe.....src="/content.html?go2Url=" + newURL width=......>

    and in your content page, use location.search & split to parse out the newURL

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2001
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't touch the content.html, but still I want to overide the variable gotoURL from the page that embed the content.html through the IFRAME tag

    Any other suggestions ?

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi ipromote,

    RE:
    I can't touch the content.html,
    Why not? And please be specific.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2001
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't have access to the content.html, that's the reason, I would like to change the variable depending on different situations.


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
  •