You are here: Reference > JavaScript > client-side > event handling > properties > uri (event)

uri property (event)

Browser support:
Returns the location of the document that caused the onmessage event.
Note: The support for the uri and domain properties has been removed in Opera 10. In Firefox, Google Chrome, Safari, Internet Explorer from version 8 and Opera from version 10, use the origin property instead.
An onmessage event occurs when the postMessage method sends a message to the current window. For details, see the pages for the postMessage method and the onmessage event.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

String that retrieves the location of the document.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the uri property:
    <script type="text/javascript">
        function Init () {
            if (window.addEventListener) {  // all browsers except IE before version 9
                window.addEventListener ("message", OnMessage, false);
            else {
                if (window.attachEvent) {   // IE before version 9
                    window.attachEvent("onmessage", OnMessage);

        function GetState () {
            var frame = document.getElementById ("myFrame");
                // send the 'getstate' message to the frame window
            var message = "getstate";
            if (frame.contentWindow.postMessage) {
                frame.contentWindow.postMessage (message, "*");
            else {
                alert ("Your browser does not support the postMessage method!");

        function OnMessage (event) {
            var message =;
            var arr = message.split (",");
            if (arr[0] == "true") {
                alert ("The check box is checked.");
            else {
                alert ("The check box is not checked.");

            var selIndex = Number (arr[1]);
            alert ("The " + (selIndex + 1) + ". option is selected.");
<body onload="Init ();">
    <iframe id="myFrame" src="message.htm" width="500" height="200px"></iframe>
    <br /><br />
    <button onclick="GetState ()">Get the state of controls in the frame</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

User Contributed Comments

Post Content

Post Content