-
אשמח אם מישהו כאן יכול לתרגם לי את הקוד דלהלן מJQuery ל j.s רגיל
// Download button (PNG) $("#download-image").on('click', function() { $(this).attr('href', $('#pdf-canvas').get(0).toDataURL()); // Specfify download option with name $(this).attr('download', 'page.png'); }); // Download button (JPEG with quality 80%) $("#download-image").on('click', function() { $(this).attr('href', $('#pdf-canvas').get(0).toDataURL("image/jpeg", 0.8)); // Specfify download option with name $(this).attr('download', 'page.jpg'); }); -
אשמח אם מישהו כאן יכול לתרגם לי את הקוד דלהלן מJQuery ל j.s רגיל
// Download button (PNG) $("#download-image").on('click', function() { $(this).attr('href', $('#pdf-canvas').get(0).toDataURL()); // Specfify download option with name $(this).attr('download', 'page.png'); }); // Download button (JPEG with quality 80%) $("#download-image").on('click', function() { $(this).attr('href', $('#pdf-canvas').get(0).toDataURL("image/jpeg", 0.8)); // Specfify download option with name $(this).attr('download', 'page.jpg'); });@ב-ל פעם הבאה תעשה גוגל
// Download button (PNG) document.getElementById('download-image').addEventListener('click', (e) => { this.attr('href', document.getElementById('pdf-canvas').get(0).toDataURL()) // Specfify download option with name this.attr('download', 'page.png') }) // Download button (JPEG with quality 80%) document.getElementById('download-image').addEventListener('click', (e) => { this.attr('href', document.getElementById('pdf-canvas').get(0).toDataURL('image/jpeg', 0.8)) // Specfify download option with name this.attr('download', 'page.jpg') }) -
@ב-ל פעם הבאה תעשה גוגל
// Download button (PNG) document.getElementById('download-image').addEventListener('click', (e) => { this.attr('href', document.getElementById('pdf-canvas').get(0).toDataURL()) // Specfify download option with name this.attr('download', 'page.png') }) // Download button (JPEG with quality 80%) document.getElementById('download-image').addEventListener('click', (e) => { this.attr('href', document.getElementById('pdf-canvas').get(0).toDataURL('image/jpeg', 0.8)) // Specfify download option with name this.attr('download', 'page.jpg') }) -
-
@ב-ל צודק, יש לומר
setAttribute// Download button (PNG) document.getElementById('download-image').addEventListener('click', (e) => { this.setAttribute('href', document.getElementById('pdf-canvas').get(0).toDataURL()) // Specfify download option with name this.setAttribute('download', 'page.png') }) // Download button (JPEG with quality 80%) document.getElementById('download-image').addEventListener('click', (e) => { this.setAttribute('href', document.getElementById('pdf-canvas').get(0).toDataURL('image/jpeg', 0.8)) // Specfify download option with name this.setAttribute('download', 'page.jpg') }) -
@ב-ל צודק, יש לומר
setAttribute// Download button (PNG) document.getElementById('download-image').addEventListener('click', (e) => { this.setAttribute('href', document.getElementById('pdf-canvas').get(0).toDataURL()) // Specfify download option with name this.setAttribute('download', 'page.png') }) // Download button (JPEG with quality 80%) document.getElementById('download-image').addEventListener('click', (e) => { this.setAttribute('href', document.getElementById('pdf-canvas').get(0).toDataURL('image/jpeg', 0.8)) // Specfify download option with name this.setAttribute('download', 'page.jpg') }) -
@ב-ל פעם הבאה תעשה גוגל
// Download button (PNG) document.getElementById('download-image').addEventListener('click', (e) => { this.attr('href', document.getElementById('pdf-canvas').get(0).toDataURL()) // Specfify download option with name this.attr('download', 'page.png') }) // Download button (JPEG with quality 80%) document.getElementById('download-image').addEventListener('click', (e) => { this.attr('href', document.getElementById('pdf-canvas').get(0).toDataURL('image/jpeg', 0.8)) // Specfify download option with name this.attr('download', 'page.jpg') }) -
@chv אמר בעזרה - .'תרגום' קטע קטן בJQuery לj.s:
document.getElementById('pdf-canvas').get(0)
כמדומני שזה אמור להחזיר רק אלמנט אחד (ולא סט), אז .get אמור להכשל.
@חגי אמר בעזרה - .'תרגום' קטע קטן בJQuery לj.s:
@chv אמר בעזרה - .'תרגום' קטע קטן בJQuery לj.s:
document.getElementById('pdf-canvas').get(0)
כמדומני שזה אמור להחזיר רק אלמנט אחד (ולא סט), אז .get אמור להכשל.
צודק..
צ"ל לקחת ישירות את ה-dataurl מהאלמנט// Download button (PNG) document.getElementById('download-image').addEventListener('click', (e) => { this.setAttribute('href', document.getElementById('pdf-canvas').toDataURL()) // Specfify download option with name this.setAttribute('download', 'page.png') }) // Download button (JPEG with quality 80%) document.getElementById('download-image').addEventListener('click', (e) => { this.setAttribute('href', document.getElementById('pdf-canvas').toDataURL('image/jpeg', 0.8)) // Specfify download option with name this.setAttribute('download', 'page.jpg') })@dovid תכל'ס - צודק..
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות