locked
SharePoint 2013 Popup dialog works fine in IE,Chrome, FireFox but in Safari opens and immediately disappears. RRS feed

  • Question

  • Hi

    I have the following JavaScript function in SharePoint 2013 which is sitting in a page and it works great in IE, Chrome and FireFox. However in Safari the popup it creates appears without an controls and then immediately disappears.

        function ShowCreateResourceDialog()
        {
            var user = document.getElementById('<%= currentLoggedInUserID.ClientID %>');

            var context = new SP.ClientContext();
            var relativeWebUrl = context.get_url();

            var options = {
                url: relativeWebUrl + "/_layouts/15/MyResources/CreatePopup.aspx?CreatedBy=" + user.value,
                title: "Create Resource",
                autoSize: false,
                width: 450,
                height: 350,
                showClose: true,
                dialogReturnValueCallback: RefreshPage
            }

            SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
        }

    I'm also having problems with controls in Safari that a post back wipes all information from the TextBox and other controls controls.

    Can anyone help?

    Tuesday, October 11, 2016 3:51 PM

Answers

  • Hi,

    Please try to use the code below in your environment. It works in my test environment.

    <script type="text/ecmascript">
    function ShowCreateResourceDialog()
    {
    	//var user = document.getElementById('<%= currentLoggedInUserID.ClientID %>');
    
    	var context = new SP.ClientContext();
    	var relativeWebUrl = context.get_url();
        console.log(relativeWebUrl);
    	var options = {
    		url:"http://www.bing.com",
    		title: "Create Resource",
    		autoSize: false,
    		width: 450,
    		height: 350,
    		showClose: true,
    		dialogReturnValueCallback: RefreshPage
    	}
    
    	SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
    }
    </script>	
    <input type="button" value="OpenPopup" onclick="ShowCreateResourceDialog()"/> 

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Proposed as answer by Patrick_Liang Friday, October 21, 2016 9:55 AM
    • Marked as answer by Patrick_Liang Friday, October 28, 2016 9:31 AM
    Wednesday, October 12, 2016 2:04 AM