create .ics file on the fly using javascript or jquery?

后端 未结 5 861
花落未央
花落未央 2021-01-30 12:08

Can someone tell me if there is any jquery plugin to dynamically create .ics file with values coming from the page div values like there would be

5条回答
  •  -上瘾入骨i
    2021-01-30 12:17

    This approach worked fine however with IE8 the browser couldn't recognize the file type and refused to open as a calendar item. To get around this i had to create the code on the server side (and exposed via RESTful service) and then set the response headers as follows;

    @GET
    @Path("generateCalendar/{alias}/{start}/{end}")
    @Produces({ "text/v-calendar" })
    public Response generateCalendar(
            @QueryParam("alias") final String argAlias,
            @QueryParam("start") final String argStart,
            @QueryParam("end") final String argEnd) {
       ResponseBuilder builder = Response.ok();
       builder.header("content-disposition", "attachment;filename=calendar.ics");
       builder.entity("BEGIN:VCALENDAR\n<........insert meeting details here......>:VCALENDAR");
       return builder.build();
    }
    

    This can be served up by calling window.location on the service URL and works on Chrome, Firefox and IE8.

    Hope this helps.

提交回复
热议问题