This is a discussion on "[SOLVED] Extracting filename without extension from variable string." within the JavaScript Forum section. This forum, and the thread "[SOLVED] Extracting filename without extension from variable string. are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] Extracting filename without extension from variable string.
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
[SOLVED] Extracting filename without extension from variable string.
Hi everybody. Here's the deal:
Page Loads, script checks URL string and finds the file name minus ".html" (or whatever the last 5 characters are) then grabs an image from the img folder that has the same name and tosses it into the page. If the file name isn't one of the four listed, a default image is loaded instead. JavaScript Code: <div align="left"><font color="#993300">
but I have a feeling if the URL ended up being "...contact.html?blahblahblah" my little script would be script-out-of-luck. How can I make sure I'm always getting the filename minus the extension and any possible passed variables. Examples are greatly appreciated since I know less than nothing about javascript. Thank you in advance. Last edited by c010depunkk; Jan 11th, 2008 at 17:02. Reason: please use [HTML] tags when posting HTML |
|
|
|
#2
|
||||
|
||||
|
Re: Extracting filename without extension from variable string.
Okay, try this.
hope that helps
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
#3
|
|||
|
|||
|
Re: Extracting filename without extension from variable string.
Rakuli, thank you very much for your help. I've found another solution for this particular problem, but your advice will come in handy in the future.
FYI, the solution I'm using now:
Thanks again. Last edited by c010depunkk; Jan 11th, 2008 at 17:02. Reason: please use [HTML] tags when posting HTML |
|
#4
|
||||
|
||||
|
Re: Extracting filename without extension from variable string.
Cool glad you sorted it.. You have to watch out though becuase if there is more than one period in the url then it will fail with your method.
My method will take away only the extensions.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Random String Verification help | psycho wolvesbane | PHP Forum | 3 | Mar 19th, 2008 09:57 |
| [SOLVED] Connection string for password protected databases | alexgeek | Classic ASP | 6 | Oct 31st, 2007 15:59 |
| [SOLVED] ASP Session Variable | Monie | Classic ASP | 7 | Oct 10th, 2007 02:44 |
| Extracting Text out of XML Nodes | DocBoy52 | Flash & Multimedia Forum | 1 | Oct 18th, 2006 14:46 |
| Assign string values to integer values of a session variable | Andy K | Classic ASP | 1 | Jul 13th, 2005 08:29 |