TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhishek Kumar
Tech Writer
558
115k
Why firefox does not create a file as csv it creates as part
Oct 30 2015 6:39 AM
Hi,
When i export html table to csv firefox is not creating as csv its creating as .csv.part.
This is my code:-
function exportTable($table, filename) {
var $rows = $table.find('tr:has(td)'),
tmpColDelim = String.fromCharCode(11),
tmpRowDelim = String.fromCharCode(0),
colDelim = ",",
rowDelim = "\r\n",
csv = $rows.map(function (i, row) {
var $row = $(row),
$cols = $row.find('td');
return $cols.map(function (j, col) {
var $col = $(col),
text = $col.text();
return text.replace(/"/g, '""');
}).get().join(tmpColDelim);
}).get().join(tmpRowDelim)
.split(tmpRowDelim).join(rowDelim)
.split(tmpColDelim).join(colDelim) ,
// Data URI
csvData = 'data:application/text;charset=utf-8,' + encodeURIComponent(csv);
$(this)
.attr({
'download': filename,
'href': csvData,
'target': '_blank'
});
}
I also used data:application/csv but it does not work.
But this code effectively works in Chrome..
Please help!!!
Thanks in advance...
Reply
Answers (
2
)
JQuery Tab validation
Show result using JQUERY in MVC