1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Pass parameters to forward framing src using JS

Discussion in 'JavaScript' started by suzanne123, Jul 30, 2009.

  1. #1
    Hi

    Is it possible to pick up parameters from the page url and add it to the forward framing SRC?

    So the result from the below www.new_website.com/page.html?ReferringagentID=1010&AnotherID=555

    Forward framing code:

    <HTML>
    <FRAMESET ROWS="*,0" FRAMEBORDER=0 BORDER=0 FRAMESPACING=0 >
    <FRAME SRC="http://www.website.com" />
    </FRAMESET>
    </HTML>

    I know of a similar code in cold fusion but I would like a JavaScript version of that.

    Similar function in Cold fusion:

    <cfif isDefined("url.ReferringAgentID")><cfset ReferringAgentId=url.ReferringAgentId><cfelse><cfset ReferringAgentId=""></cfif>

    Then at the end of the link to open a page add:

    ?ReferringAgentId=<cfoutput>#ReferringAgentId#</cfoutput>



    Any help in this would be much appreciated
     
    suzanne123, Jul 30, 2009 IP
  2. 1 FineLine

    1 FineLine Peon

    Messages:
    78
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ReferringagentID=1010&AnotherID=555

    is referencing fields in a database correct?

    Can JS pull content from a database? Not sure. That is probably why they used CF or PHP.

    The only other way I can think of is using the document.referrer and append this to the URL. However this is a security risk if you're using sensitive data.
     
    1 FineLine, Aug 4, 2009 IP
  3. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Try a js function like this,

    
    function displayUrlParameters()
    {
      var urlValue = window.location;
    
      var urlText = urlValue.toString();
    
      var start = urlText.indexOf("?") + 1;
    
      var paramText = urlText.substring(start, urlText.length);
    
      var params = paramText.split("&");
    
      var paramName = new Array(params.length);
    
      var paramValue = new Array(params.length);
    
      for(var i=0; i<params.length; i++)
      {
         start = params[i].indexOf("=") + 1;
     
         paramName[i] = params[i].substring(0, start);
    
         paramValue[i] = params[i].substring(start, params[i].length);   
      }
    
      // Display parameter name and value
    
      for(var i=0; i<params.length; i++)
      {  
         document.getElementById('MyDiv').innerHTML += paramName[i] + " = " + paramValue[i] + "<br/>"
      }
    
    }
    
    Code (markup):
    You can call this function on page load.

    Didnt get the time to test the code.

    Relpy if u find any difficulties.

    Hope this helps.
     
    Unni krishnan, Aug 4, 2009 IP