Click here to Skip to main content
16,012,223 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

Can u Please tell me how can i fetch value from any active page URL, and once i got that value if it contain, then i would like to open new window.
here i m givng example suppose this is my current URL with new window open once i click button
( https://tools.gakgs.com/gdrp/coiga/showsurvey.do?surveyCode=7189&keyCode=000038167 )

now i want to check for " keycode value" and if it found i want to open new window with keycode value

( https://secure.lomadee.com/at/actionlog" + "?transaction=" + KeyCode + ">" + "&adv=5742&country=AR&event=12583 )

Please help me.


Thanks in advance....
Posted
Updated 25-Sep-12 19:36pm
v2
Comments
Sandeep Mewara 26-Sep-12 2:12am    
Not clear to me atleast. Please rephrase.
rajdeep kumar 26-Sep-12 2:56am    
Hey Sandeep,

Suppose i clicked button in my html page, which will open a new page with URL given below, for eg..

[ "https://tools.cisco.com/gdrp/coiga/showsurvey.do?surveyCode=7189&keyCode=000038167&gId=dssd" ]

now once it opened, i want to search for keycode in current URL,if it found then fetch the keycode value(000038167) and open the another page with URL like

[ "https://secure.aaaaa.com/at/actionlog" + "?transaction=" + KeyCode + ">" + "&adv=5742&country=AR&event=12583" ]

else show with some default keycode value..

Could u plz tell me how to do this stuff,how to write javascript function and call it from my HTML page.

1 solution

You can retrieve the querystring from the url using the function below (taken from StackOverflow: how-can-i-get-query-string-values[^]):

C#
function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.search);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}


I will leave opening the new window part to you (hint: window.open).

Hope that helps!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900