Click here to Skip to main content
15,898,134 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: javascript code to disable window button in html page?? Pin
Richard MacCutchan30-Dec-17 21:43
mveRichard MacCutchan30-Dec-17 21:43 
QuestionGear generator Java Pin
Member 1358988322-Dec-17 0:34
Member 1358988322-Dec-17 0:34 
AnswerRe: Gear generator Java Pin
Richard MacCutchan22-Dec-17 1:15
mveRichard MacCutchan22-Dec-17 1:15 
QuestionI need to regenerate the excel columns as well whenever the drop down changes. javscript mvc Pin
Member 1336752712-Dec-17 22:26
Member 1336752712-Dec-17 22:26 
QuestionHow to build a simple web crawler that gets events for a future date? Pin
Member 135663578-Dec-17 21:34
Member 135663578-Dec-17 21:34 
AnswerRe: How to build a simple web crawler that gets events for a future date? Pin
Richard MacCutchan8-Dec-17 22:29
mveRichard MacCutchan8-Dec-17 22:29 
GeneralRe: How to build a simple web crawler that gets events for a future date? Pin
Member 135663578-Dec-17 22:30
Member 135663578-Dec-17 22:30 
QuestionGet image dimensions Pin
cre8tivedaze2-Dec-17 23:50
cre8tivedaze2-Dec-17 23:50 
Hi Guys,

Hoping someone can help me out. I'm trying to display a thumbnail of an image but for some reason I can't seem to get the naturalHeight/naturalWidth or heigh/width of the image. I'm using the RadAsyncUpload control from Telerik in a Ajax environment. during debugging I can see all of the other details about the file but the height/widths are always 0.

Here's my script

JavaScript
<pre>        <script type="text/javascript">

            function OnClientFileSelected(sender, args) {
                if ($telerik.isIE9 || $telerik.isIE8 || $telerik.isIE7) {
                    var input = args.get_fileInputField();
                    if (sender.isExtensionValid(input.value)) {
                        var img = document.createElement("img");
                        var thumbnail = document.getElementById("thumbnail");
                        thumbnail.appendChild(img);
                        if (img) {
                            img.style.visibility = "";
                            img.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = input.value;
                        }
                    }
                }
                else {
                    var file = args.get_fileInputField().files.item(args.get_rowIndex()),
                        index = 0;
                    while (!file) {
                        file = args.get_fileInputField().files.item(index);
                        index++;
                    }
                    var $row = $telerik.$(args.get_row());
                    showThumbnail(file, $row);
                    
                }

            }


            function showThumbnail(file, row) {

                var image = document.createElement("img"),
                    thumbnail = document.getElementById(row.context.id),
                    breakLine = document.createElement("br");
                image.file = file;
                thumbnail.appendChild(breakLine);
                thumbnail.appendChild(image);

                var reader = new FileReader()
                reader.onload = (function (aImg) {
                    return function (e) {
                        aImg.src = e.target.result;
                    };
                }(image))
                var ret = reader.readAsDataURL(file),
                    canvas = document.createElement("canvas");

                ctx = canvas.getContext("2d");
                image.onload = function () {
                    ctx.drawImage(image, 10, 10, 150, 180);
                }

                if (image.naturalWidth > image.naturalHeight) {
                    if (image.naturalWidth > MAX_WIDTH) {
                        height *= MAX_WIDTH / image.naturalWidth;
                        width = MAX_WIDTH;
                    }
                } else {
                    if (image.naturalHeight > MAX_HEIGHT) {
                        width *= MAX_HEIGHT / image.naturalHeight;
                        height = MAX_HEIGHT;
                    }
                }

                var MAX_WIDTH = 800,
                    MAX_HEIGHT = 600,
                    width = image.naturalWidth,
                    height = image.naturalHeight;

                canvas.width = width;
                canvas.height = height;
              

                var dataurl = canvas.toDataURL("image/png");
            }

        </script>

AnswerRe: Get image dimensions Pin
debasish mishra23-Jan-18 19:23
professionaldebasish mishra23-Jan-18 19:23 
QuestionJavaScript Pin
Rhiz Mariel Diesta1-Dec-17 4:36
Rhiz Mariel Diesta1-Dec-17 4:36 
AnswerRe: JavaScript Pin
Richard MacCutchan1-Dec-17 8:11
mveRichard MacCutchan1-Dec-17 8:11 
GeneralRe: JavaScript Pin
ZurdoDev1-Dec-17 8:41
professionalZurdoDev1-Dec-17 8:41 
GeneralRe: JavaScript Pin
Rhiz Mariel Diesta1-Dec-17 8:52
Rhiz Mariel Diesta1-Dec-17 8:52 
GeneralRe: JavaScript Pin
ZurdoDev1-Dec-17 8:55
professionalZurdoDev1-Dec-17 8:55 
AnswerRe: JavaScript Pin
ZurdoDev1-Dec-17 8:40
professionalZurdoDev1-Dec-17 8:40 
GeneralRe: JavaScript Pin
Nathan Minier4-Dec-17 1:22
professionalNathan Minier4-Dec-17 1:22 
QuestionJavaScript Pin
Rhiz Mariel Diesta1-Dec-17 3:55
Rhiz Mariel Diesta1-Dec-17 3:55 
AnswerRe: JavaScript Pin
Afzaal Ahmad Zeeshan1-Dec-17 4:25
professionalAfzaal Ahmad Zeeshan1-Dec-17 4:25 
AnswerRe: JavaScript Pin
Richard MacCutchan1-Dec-17 4:28
mveRichard MacCutchan1-Dec-17 4:28 
AnswerRe: JavaScript Pin
ZurdoDev1-Dec-17 9:08
professionalZurdoDev1-Dec-17 9:08 
GeneralRe: JavaScript Pin
Rhiz Mariel Diesta1-Dec-17 9:58
Rhiz Mariel Diesta1-Dec-17 9:58 
GeneralRe: JavaScript Pin
ZurdoDev1-Dec-17 10:02
professionalZurdoDev1-Dec-17 10:02 
QuestionGetting the Name of the Browser Pin
BobInNJ28-Nov-17 5:50
BobInNJ28-Nov-17 5:50 
AnswerRe: Getting the Name of the Browser Pin
F-ES Sitecore28-Nov-17 6:06
professionalF-ES Sitecore28-Nov-17 6:06 
GeneralRe: Getting the Name of the Browser Pin
mappleleaf29-Nov-17 11:43
mappleleaf29-Nov-17 11:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.