Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Jun 2012
    Thanked 0 Times in 0 Posts

    Question JavaScript Generate URL

    To anyone that can help me, Good Morning (NZ TIME)

    I am in the process of configuring a webpage that generates a URL when you input certain information.

    I am using the Facebook Page Tab Tutorial to make this easy page for adding tabs to pages quickly.

    Anyway. This is what I've done so far: You can also see it in action.

    <script type="text/javascript">
    function changeText2(){
        var yourAPPID = document.getElementById('yourAPPID').value;
        var yourSOURCEURL = document.getElementById('yourSOURCEURL').value;
        var lnk = document.getElementById('lnk');
        lnk.href = "http://www.facebook.com/dialog/pagetab" + "?app_id=" + yourAPPID + "&next=" + yourSOURCEURL;
        lnk.innerHTML = lnk.href;
    Here is the insert tab URL: --> <a href="" id=lnk target="_blank">nothing here yet</a> <br> <br>
    What is the APP ID?      <input type='text' id='yourAPPID' value='Your APP ID' onKeyup='Javascript: if (event.keyCode==13) changeText2()'/> <br>
    What is the SOURCE URL?  <input type='text' id='yourSOURCEURL' value='Your SOURCE URL' onKeyup='Javascript: if (event.keyCode==13) changeText2()'/> <br> <br>
    <input type='button' onclick='changeText2()' value='Change the insert tab URL'/>
    What I want to do
    • Make pressing the enter key/clicking the button automatically go to the generated 'insert tab URL' (maybe after a certain time, say 3 seconds). This is the lnk variable. The enter key is keyCode==13.
    • Part One - Incorporate the enter key/clicking button going to page after 3 seconds, and;
      Part Two - Adapt this 'update as you go' search box code to do the same as what i have already done, shown earlier. Use the same variables yourAPPID, yourSOURCEURL and name the function changeText2(). Delete/Change the variables etc... as required to match the webpage code I have already done.

    <a id="reflectedlink" href="http://www.google.com/search">http://www.google.com/search</a>
    <input id="searchterm"/>
    <script type="text/javascript">
        var link= document.getElementById('reflectedlink');
        var input= document.getElementById('searchterm');
        input.onchange=input.onkeyup= function() {
            link.search= '?q='+encodeURIComponent(input.value);
            link.firstChild.data= link.href;
    All help is gratefully appreciated and I am new to this sort of thing

    I look forward to a reply.

    Kind Regards,
    Mark Wasley
    Last edited by Mark Wasley; 12-11-2012 at 08:08 PM. Reason: It is now morning


Tags for this Thread

Posting Permissions

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