homepage Welcome to WebmasterWorld Guest from 54.205.236.46
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
URL Decoding
Revata




msg:4023480
 12:35 am on Nov 12, 2009 (gmt 0)

My Javascript isn't very strong, but I've got an event listener that will show a filename when a media file is selected. The script looks like this:


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

...because some of the files have urlencoded filenames I want them to appear without the %27's and such, so I tried this:


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

But since it's expecting a string in the unescape argument it doesnt work. Is there any way I can change the command so that it'll urldecode the filename rather than the word "file" in this case?

 

Fotiman




msg:4024377
 2:06 pm on Nov 13, 2009 (gmt 0)

player.getPlaylist()[obj.index]._utf8_decode(unescape(file.split('/')[1].split('.')[0])) + '</span>';

Does that work?

Revata




msg:4028216
 6:14 pm on Nov 19, 2009 (gmt 0)

Hm, that didn't work. In fact, entering "_utf8_decode(unescape())" in the command breaks the entire innerHTML. It doesnt even display "Now Playing: ".

I wonder is there any other way to decode other than with: _utf8_decode ?

Fotiman




msg:4028255
 7:09 pm on Nov 19, 2009 (gmt 0)

How about this?


function itemMonitor(obj) {
var str = '<span class="style1">Now Playing: ',
filename = player.getPlaylist()[obj.index].file.split('/')[1].split('.')[0];
filename = unescape(filename);
str += filename + '</span>';
gid('nowplaying').innerHTML = str;
}

Revata




msg:4028294
 8:09 pm on Nov 19, 2009 (gmt 0)

Success! That works, thanks for the help Fotiman. =)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved