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

后端 未结 5 865
花落未央
花落未央 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条回答
  •  面向向阳花
    2021-01-30 12:24

    you will need to make it in ICS format. also you will need to convert the date and time zone; E.G. 20120315T170000Z or yyyymmddThhmmssZ

        msgData1 = $('.start-time').text();
        msgData2 = $('.end-time').text();
        msgData3 = $('.Location').text();
    
        var icsMSG = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Our Company//NONSGML v1.0//EN\nBEGIN:VEVENT\nUID:me@google.com\nDTSTAMP:20120315T170000Z\nATTENDEE;CN=My Self ;RSVP=TRUE:MAILTO:me@gmail.com\nORGANIZER;CN=Me:MAILTO::me@gmail.com\nDTSTART:" + msgData1 +"\nDTEND:" + msgData2 +"\nLOCATION:" + msgData3 + "\nSUMMARY:Our Meeting Office\nEND:VEVENT\nEND:VCALENDAR";
    
        $('.test').click(function(){
            window.open( "data:text/calendar;charset=utf8," + escape(icsMSG));
        });
    

    the above sample will create a ics file for download. the user will have to open it and outlock, iCal, or google calendar will do the rest.

提交回复
热议问题