JavaScript - Getting Url Parts
Hi I am trying to get the url parts using javascript
my url looks like this http://domain/#/Home I need to get the "Home" piece of the url I tried window.location.pathname but it only returns / can anybody help? Similar TutorialsIf I wanted to extract certain parts of the URL... how can I do this? I know how to extract the entire URL or just the search query but what if i want to do this /boxscore.asp?w=2&s=4&yr= Just extract the numbers 2 and 4 from the url. I want to make a new link for this site I am on to plug those 2 numbers into here /game.asp?gnum=2&gslot=4 That's basically what i want the new window to read. I would appreciate assistance with the following case. Thank you in advance. I have two fields with values, e.g. Field1: 123456-1- 01 Field2: 01 -0001 I need to compare the last two digits of Field1( 01 ) against the First two digits of Field2 ( 01 ) I would assume OnChange moving from Field2. If the two do not match throw an alert. Thanks!! This is my first post. I am reading "Javascript The Good Parts" ~ The Method Invocation Pattern Page 28 and tried this, var myObject= { value:0, increment:function(inc){ this.value+= typeof inc==="number" ? inc:1; } } myObject.increment(2); alert(myObject.value); but alert(myObject.value); is returning a value of "2", when it should return "3". Can someone help? Reply With Quote 12-22-2014, 09:59 AM #2 rnd me View Profile View Forum Posts Visit Homepage Senior Coder Join Date Jun 2007 Location Urbana Posts 4,497 Thanks 11 Thanked 603 Times in 583 Posts 0+2=2, not 3; the code is working correctly. |