Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Strip File Extensions

Javascript to strip last 4 characters?

12:17 am on May 16, 2009 (gmt 0)

5+ Year Member

I'm building a page with a media player and playlist. On each playlist item i have a 'play' link that fires off a load command and a play command to the player.

I also have a "Now Playing" Div that listens for a new file to start and displays the filename. So it would display, "Now Playing: video.flv" or something like that.

My question is, is there a way to write some Javascript inline that will strip the extension off of the video's file name?

Here's the 'now playing' script:

<script type="text/javascript">
var player = null;

function playerReady(obj)
player = gid(obj.id);

function itemMonitor(obj)
gid('nowplaying').innerHTML = '<span class="style1">Now Playing: ' + player.getPlaylist()[obj.index].file + '</span>';

function displayFirstItem()
player.addControllerListener('ITEM', 'itemMonitor');

function gid(name)
return document.getElementById(name);

2:00 am on May 16, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



to display up to first '.'

2:17 am on May 16, 2009 (gmt 0)

5+ Year Member

Perfect! Works like a charm. Thank you thank you!

Featured Threads

Hot Threads This Week

Hot Threads This Month