Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing values one page to another

    Hi

    I have an index page which has link to another page(say pageA). In the src of the link, i pass the value as pageA.html?msg=msgValue.

    pageA.html is like this,

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript" SRC="script.js">
    </SCRIPT>
    <title>Global Electronic Compound Aggregation</title>
    <!-- header info used to contain extra information about
    this document, not displayed on the page -->
    <link rel="stylesheet"
    type="text/css" href="font.css" />
    </head>
    <body>
    <FRAMESET rows="15%,89%" cols="*">
    <FRAME id="title" SRC="title.html?site=US" name="title">
    <FRAMESET rows="*" cols="13%,64%,23%">
    <FRAME id="menu" SRC="menu.html?site=US">
    <FRAME id="about" SRC="detail.html?site=US" name="detail">
    <FRAME id="quickLaunch" SRC="launch.html?site=US">
    </FRAMESET>
    </FRAMESET>
    <body> </body>
    </html>my question is, how do I attach the msg=msgValue from the index page to all the other pages in the frameset. I want something like,

    title.html?site=US&msg=msgValue
    menu.html?site=US&msg=msgValue
    detail.html?site=US&msg=msgValue
    launch.html?site=US&msg=msgValue

    I tried writing a javascript on the onLoad() of the Frameset but it does not work.

    My Java script looked like,

    Code:
    function appendSiteEnv(hiddenValue)
    {
    document.getElementById('title').setAttribute('href','title.html.html?site='+hiddenValue+'&env='+get Env());
    document.getElementById('menu').setAttribute('href','menu.html?site='+hiddenValue+'&env='+getEnv());
    document.getElementById('about').setAttribute('href','detail.html?site='+hiddenValue+'&env='+getEnv( ));
    document.getElementById('launch').setAttribute('href','quickLaunch.html?site='+hiddenValue+'&env='+g etEnv());
    }

    function getEnv()
    {
    env="";
    var arrArgs = location.search.substring(1).split("&");
    if(arrArgs.length>1)
    env=arrArgs[1].substring(arrArgs[1].indexOf("=")+1);
    else if(arrArgs.length==1)
    env=arrArgs[0].substring(arrArgs[0].indexOf("=")+1);
    return env;
    }
    Any help is greatly appreciated

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Are you not using a server-side language like PHP, ASP, JSP, etc? It's very easily done using a server-side language and the most recommended solution as it cannot be disabled like Javascript.

    If you really don't use a server-side language, then you can do it like this:
    Code:
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript" SRC="script.js">
    </SCRIPT>
    <script type="text/javascript">
    function init(){
      document.getElementById("title").src = "title.html?site=US&env=" + getEnv();
      document.getElementById("menu").src = "menu.html?site=US&env=" + getEnv();
      document.getElementById("about").src = "detail.html?site=US&env=" + getEnv();
      document.getElementById("quickLaunch").src = "tlaunch.html?site=US&env=" + getEnv();
    }
    
    function getEnv()
    {
      var env="";
      var arrArgs = location.search.substring(1).split("&");
      if(arrArgs.length>1)
        env=arrArgs[1].substring(arrArgs[1].indexOf("=")+1);
      else if(arrArgs.length==1)
        env=arrArgs[0].substring(arrArgs[0].indexOf("=")+1);
      return env;
    }
    
    window.onload = init;
    </script>
    <title>Global Electronic Compound Aggregation</title>
    <!-- header info used to contain extra information about
    this document, not displayed on the page -->
    <link rel="stylesheet" 
    type="text/css" href="font.css" />
    </head>
    <FRAMESET rows="15%,89%" cols="*"> 
    <FRAME id="title" SRC="about:blank" name="title"> 
    <FRAMESET rows="*" cols="13%,64%,23%"> 
    <FRAME id="menu" SRC="about:blank"> 
    <FRAME id="about" SRC="about:blank" name="detail"> 
    <FRAME id="quickLaunch" SRC="about:blank"> 
    </FRAMESET>
    </FRAMESET>
    </html>

  • #3
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Glenn, it works great.


  •  

    Posting Permissions

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