Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-11-2012, 04:25 AM   PM User | #1
Mark Wasley
New Coder

 
Join Date: Jun 2012
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Mark Wasley is an unknown quantity at this point
Question Generate URL through JavaScript

To anyone that can help me, Good Afternoon (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.

Code:
<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;
}
</script>
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.

Code:
<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;
    };
</script>
All help is gratefully appreciated and I am new to this sort of thing

I look forward to a reply.

Kind Regards,
Mark Wasley
Mark Wasley is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:59 AM.


Advertisement
Log in to turn off these ads.