web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Image not displaying in Web Resource.

(0) ShareShare
ReportReport
Posted on by

I have an HTML code which should display an image on a form after loading it but currently its not.

My code looks like 

<html>
<head>
<style>
</style>
<script>
function load()
{
window.parent.document.getElementById("customerAssetImage").src = imageUrl;
Xrm.Page.getAttribute("customerAssetImage").src = imageUrl;
}
</script>
</head>
<body onload="load()" style='word-wrap: break-word;'>
<img src="nothing.jpg" id="customerAssetImage" name="customerAssetImage"/>
</body>
</html>
I used two ways to set an image
1) window.parent.document.getElementById("customerAssetImage").src = imageUrl;
2) Xrm.Page.getAttribute("customerAssetImage").src = imageUrl;
But none seems to work. Attaching the snapshot of how it looks right now.

4152.error.PNG
Could someone please tell what's wrong with the code? Any help much appreciated.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    1) window.parent.document.getElementById("customerAssetImage").src = imageUrl;

    This is useful when you want to set the src of img control in parent window. In this case your HTML page should be embedded/part of another page. This is not applicable for you.

    2) Xrm.Page.getAttribute("customerAssetImage").src = imageUrl;

    Xrm syntax is for CRM only context. This syntax will never work as there is no img control in CRM. Only iframe url can be set like this.

    Solution: You should try this syntax because you are setting img url within same window.

    document.getElementById("customerAssetImage").src = imageUrl;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans