简体   繁体   中英

CRM 2011 HTML WebResource: getContext produces “Object doesn't support property or method”

I'm creating an HTML web-resource for CRM 2011 that is suppose to produce a custom graph. It works great on my local machine, but as soon as I put it into the CRM 2011 Solution, I get a JavaScript error on the line where I call getContext() on an element.

I've even gone so far as strip the code down to the most basic elements, and it still produces this error in CRM. Does anyone have any ideas? You can see the stripped down code below.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<div style="width: 50%">
    <canvas id="myChart" width="400" height="300"></canvas>
</div>

<script>

    function loadData(dataSet) {

        var c = document.getElementById("myChart");
        var ctx = c.getContext(); //THIS IS THE LINE PRODUCING THE ERROR, BUT ONLY IN CRM 2011!!!
    }

    window.onload = function () {
        loadData(1);
    }
</script>
</body>
</html>

Turns out it's because the CRM environment that I'm using has IE8, which does not fully support HTML5. My development machine has IE11 installed, which is why it worked for me while developing the solution.

I just spoke to our network guys, and they're going to try to have IE upgraded on the CRM boxes as soon as possible.


Just a quick update, after having IE upgraded to 11 and installing quite a few service packs, I opened up CRM 2011 and it went into Mobile mode. We had to assign the domain name to the Compatability View list and that made it behave normally again. With that though, I had to add the following line to the HTML in order for the HTML5 to behave properly again:

<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> <!-- this is the line that was added -->

Hopefully this will help anyone else down the road.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM