Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - Rewriting one part of a URL into a link -


i trying 1 part of url insert another.

url in address bar read domain.com/test.php?/12345 link in page must become domain.com/do/login/12345 (this end number change every user)

(note can't change url domain.com/test.php?/12345 has been set site owner.)

for urls above had remove http://www. part above new user can't submit more 1 link spam prevention. final script should include http://www.

you able see need number @ end ie 12345 i'm not sure how achieve (javascript beginner). have far:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>path test</title> </head>  <body>  <script> // url eg http://www.domain.com/test.php?/12345 newurl = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname; </script>  <script> //write new domain add user number ie 12345 document.write('http://www.domain.com/do/login/' + window.location.pathname); </script> </body> </html> 

this not work shows got to.

i've had luck using script found @ http://www.sitepoint.com/forums/showthread.php?t=244955 worked filenames extension name on .html, .php etc.

any ideas?

thanks in advance.

first, need part of url after question mark. available in the

 window.location.search 

variable. note that includes "/". need create actual link. document.write('http://...) won't work because write in text form , not actual anchor tag. need like:

document.getelementbyid("yourlink").href = "http://domain.com/do/login" + window.location.search 

don't forget put anchor tag in html id matches element in getelementbyid() method above. if don't want put anchor tag in html markup, can create 1 javascript like:

var link = document.createelement('a'); link.href = "http://domain.com/do/login" + window.location.search; document.body.appendchild(link); 

this may need further adjusting needs.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -