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 13 of 13
  1. #1
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts

    adding variable to end of frame url

    Hi, i have this little script which grabs part of the current url and puts it into a javascript variable.

    Code:
    var URL = unescape(window.document.location);
    
    if (URL.indexOf("?") > -1) { 
    //whether the location contains a "?" or not
    
    var list1 = URL.split("?");
    //split at "?";
    var list2 = list1[1].split ("=");
    //split at "=";
    var list2[0] = list2[1];
    //assignment
    }
    So if my user was directed to
    www.mywebsite.com/search.html?string=1
    the string would become 'list2'.

    My search.html page is made up of 2 frames, so my question is how can i pass this variable to the end of one of the urls for one of the frames? So the page will load a different address in one frame depending on the string name that is entered between the ? and the =.

    Here is what i have so far:

    Code:
    <head>
    
    
    <META HTTP-EQUIV="CHARSET" CONTENT="ISO-8859-1">
    <META HTTP-EQUIV="CONTENT-LANGUAGE" CONTENT="English">
    <META HTTP-EQUIV="VW96.OBJECTTYPE" CONTENT="Document">
    <META NAME="RATING" CONTENT="General">
    <META NAME="ROBOTS" CONTENT="index,follow">
    <META NAME="REVISIT-AFTER" CONTENT="1 Days">
    <LINK REL="STYLESHEET" TYPE="TEXT/CSS" HREF="style.css">
    </HEAD>
    
    <script language="JavaScript" type="text/JavaScript">
    
    var URL = unescape(window.document.location);
    
    if (URL.indexOf("?") > -1) { 
    //whether the location contains a "?" or not
    
    var list1 = URL.split("?");
    //split at "?";
    var list2 = list1[1].split ("=");
    //split at "=";
    var list2[0] = list2[1];
    //assignment
    }
    
    </script>
    
    <FRAMESET COLS="22%,78%" BORDER="0" FRAMEBORDER="0" FRAMESPACING="0">
    <FRAME NAME="MENU" SRC="http://mysite.com/sidemenu.htm" BORDER="0" FRAMEBORDER="0" FRAMESPACING="0">
    <FRAME NAME="MAIN" SRC="http://www.google.com/search?q=" BORDER="0" FRAMEBORDER="0" FRAMESPACING="0">
    <FRAMESET ROWS="100%" BORDER="0" FRAMEBORDER="0" FRAMESPACING="0">
    </FRAMESET>

    Many thanks if you can help in any way.
    Last edited by bunion; 07-06-2005 at 01:19 AM.

  • #2
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    bumpage

  • #3
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    there are quite a few url variable 'grabbers' posted on the forums. then to call it out to a frame you would use document.frames['frame_id'].location = varX; would you not?
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #4
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Ok, i tried everything including your suggestion but could not get it working. I have found another small script that will put whatever is after the ? at the end of the address into a variable for me. (ThisAffiliateCode) All i want to do is place this variable at the end of the address for the second frame. I have done loads of searching but nothing seems to work for me. Here is my new code, if anyone could point out what minor adjustment (well i think its minor) is needed it would be really appreciated.

    Code:
    <html> 
    <head> 
    <title>Testing</title> 
    </head> 
    
    <script type="text/javascript" language="JavaScript"><!--
    
    function GetAffiliateCode() {
    var DefaultAffiliateCode = 'Enter_a_code';
    var thisurl = location.href;
    var ql = thisurl.indexOf('?
    if(ql < 0) { ql = thisurl.indexOf('# }
    if(ql >= 0) { return thisurl.substr(ql + 1); }
    return DefaultAffiliateCode;
    ThisAffiliateCode = GetAffiliateCode();
    parent.content.location='http://www.google.com/search?q='+ThisAffiliateCode+';
    }
    //-->
    
    </script>
    
    <FRAMESET COLS="22%,78%" BORDER="0" FRAMEBORDER="0" FRAMESPACING="0">
    <frame src="http://mysite.com/sidemenu.htm" name="nav">
    <frame src="http://www.google.com/search?q=" name="content">
    </frameset>
    
    </html>

  • #5
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Is it because the function is not running on page load? Or is it running?! help! noob!

  • #6
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, maybe it's just me, but i'm not really understanding what you want here.

    you want to post a variable from one frame to another?

    so like if a use presses a button on Frame1 the variable 'var1' gets sent to Frame2 via the url?
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #7
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Ok imagine someone typed in the address bar

    www.mysearchsite.com?example

    The page that would load would be made from 2 frames. I would somehow like the word example (or whatever is there after the ?) to be added on to the end of the URL for the second frame. I dont want to post a variable from one frame to the other, i want to post a variable from the address in the address bar to the end of the second frames address. So the frameset code would become

    <FRAMESET COLS="22%,78%" BORDER="0" FRAMEBORDER="0" FRAMESPACING="0">
    <frame src="http://mysearchsite.com/sidemenu.htm" name="nav">
    <frame src="http://www.google.com/search?q=example" name="content">
    </frameset>

    Thanks for the help so far though.

  • #8
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, i'l look into this when i get home from work. it can be done.


    now will you know what the variable will be (the text after the question mark)?
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #9
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    All i know is that what is after the question mark could be just letters or numbers or a mixture of both.

  • #10
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,064
    Thanks
    0
    Thanked 15 Times in 15 Posts
    See if this doesn't help you... The purpose and method are a little different but the end result is the same...

    http://www.codingforums.com/showpost...37&postcount=2

    HTH,

    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #11
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    That did it! Thankyou very much!

  • #12
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Im trying to do a similar thing but just with a pop up window but it wont work. Can anyone see whats wrong with my code? For example, if the url below was used the idea is that http://www.google.com/search?q=testing would be shown in the popup.

    http://mysite.com/popup.html?newLink=testing


    popup.html >
    Code:
    <HTML>
    <HEAD>
    
    <SCRIPT LANGUAGE="JavaScript">
    
    function getParams() {
    var idx = document.URL.indexOf('?');
    var params = new Array();
    if (idx != -1) {
    var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
    for (var i=0; i<pairs.length; i++) {
    nameVal = pairs[i].split('=');
    params[nameVal[0]] = nameVal[1];
       }
    }
    return params;
    }
    params = getParams();
    
    function popUp(URL) {
    
    newLink = unescape(params["newLink"]);
    newAnchor = unescape(params["newAnchor"]);
    
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + newLink + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=500,left = 470,top = 200');");
    }
    
    
    
    
    
    </SCRIPT>
    
    
    </HEAD>
    
    
    
    
    <BODY onLoad="javascript:popUp('http://www.google.com/search?q=')">
    
    </BODY>
    
    </HTML>

  • #13
    New Coder
    Join Date
    Dec 2004
    Posts
    86
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Did it.


  •  

    Posting Permissions

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