Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6098377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:09:04+00:00 2026-05-23T13:09:04+00:00

I found the JavaScript to break up the queryString of a page and pull

  • 0

I found the JavaScript to break up the queryString of a page and pull a variable from it. I needed to do this so that I could create a new link that would put the website into a facebook app I am trying. Basically, we upload pages to our server which generates a long value (k). So, the URL is always http://www.oursite.com/webhost/login.asp?k=12342342334 etc.

Here is what I have so far:

function querySt(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i=0;i<gy.length;i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
    var SurveyKey = querySt("k");
    var url = "http://apps.facebook.com/appname/k=" + SurveyKey;
    window.location = url;
}

So, I have a var called “url” which should give the correct URL for what I need it to do (basically just sets the page in a facebook canvas). I seem to be lost on how to make create a link for this.

It needs to be a button that someone clicks and it just opens a new window with the var url. What am I missing here? I tried

document.write="<a href="url...

but I can’t reference that variable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:09:04+00:00Added an answer on May 23, 2026 at 1:09 pm

    Why not use PHP for it instead of Javascript? If you extract the variable from the URL in PHP you can just make the link:

    <a href="www.oursite.com/webhost/login.asp?k=<?=$your_key?>">test</a>
    

    If you want to do it in javascript:

    var url;
    function querySt(ji) {
        hu = window.location.search.substring(1);
        gy = hu.split("&");
        for (i=0;i<gy.length;i++) {
            ft = gy[i].split("=");
            if (ft[0] == ji) {
                return ft[1];
            }
        }
        var SurveyKey = querySt("k");
        url = "http://apps.facebook.com/appname/k=" + SurveyKey;
    
        insertInPage();
    }
    
    function insertInPage() {
        var content = "<a href=\"" + url + "\">link</a>"
        document.write(content);
        // or:   document.getElementById("your_id").innerHtml = content;
    }
    

    Something along those lines at least.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

javascripthere is the script found at Javascript: how to get text nodes following/preceding break
Awhile back, I found the following javascript function that allows you to dynamically add
I just found out about using label s in JavaScript, such as: for (var
I've been arguing for some time against embedding server-side tags in JavaScript code, but
Javascript (ECMAscript) supports the Array.prototype.forEach method since version 1.6 (ECMAscript edition 3, 2005). So
I have been writing a JavaScript library for a few weeks now and it
UPDATE : Once I looked at the problem in Firebug, I found my mistake
String.prototype.is_email = function() { return this.match(/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)b/); }; I'm trying to get all my javascript
I've got a form that gets shown via a simplemodal popup and one of
So loading up our new web application in Firefox and Chrome I had an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.