Reputation: 39118
This is weird and I feel sort-of-stupid.
In CRM, I hit F12 and checked that the yellow warning section is a DIV with id Notifications (and sub-DIVs called Notification0, Notification1 etc.).
However, when I went document.getElementById("Notifications")
, I got squat. WTF?!
Also, when I went document.write("")
, nothing changed. In Cr and FF, it did but IE didn't react. Am I insane?
EDIT:
The above is a typo. When I try to execute:
document.getElementById("crmNotifications")
I get nada, neither... Suggestions?
Upvotes: 1
Views: 1142
Reputation: 3553
You are not insane, and nothing wrong with CRM and browser too :)
If you are running javascript from the Console of the browser, you are in context of window
of the whole page. However CRM forms content is lied inside contentIFrame
iframe. IFrames actually are separate pages, you can even edit link to which this iframe points in F12 developer tools to any other link you want. Try to change src
attribute in it to http://www.bing.com
and you will see Bing home page inside CRM window (only ribbon will remain):
<iframe title="This is IFrame" id="contentIFrame" src="http://www.bing.com"
style="width: 100%; height: 100%; border-top-style: none;
border-right-style: none; border-bottom-style: none;
border-left-style: none; display: inline;" >
That's why you cannot get crmNotifications
DOM element - because when running javascript from Console you are in context of parent window. When you specify window.frames[0]
it will give you the first IFrame on the page (actually this is only one there), inside it you will be able to get crmNotifications
, because it is there.
When you are running custom scripts which you have added via CRM customization - they are linked to the inner form page (to which IFrame points), that's why from those scripts you can get crmNotifications
directly, because you are already on 'content' page context.
Upvotes: 4
Reputation: 6715
Try
frames[0].document.getElementById('crmNotifications')
For whatever reason in IE you need the frames[0]
bit. It is the same if you want to use the Xrm
object too.
Upvotes: 1
Reputation: 2507
You aren't insane perhaps a little :D if i see well Notifications is the class not the id. The id is crmNotifications. I write notifications and i have this link in my bookmarks.
Upvotes: 3