Client Object Model Javascript and web url issue:
o
I
found the solution. Check the view source of any sharepoint page in SP2013. I
found a javascript variable 'L_Menu_BaseUrl' which holds the web relative Url.
o
SharePoint
2013 with IE11: L_Menu_BaseUrl is undefined.
Unfortunately these variable disappeared when I
updated to IE 11.
o
This
problem is present in SP2013 in IE11 only, and the strange thing is that if you
switch on the compatibility mode (or changes the user agent string using F12)
the variables return.
o
So I replaced
the L_Menu_BaseUrl to hidden filed value(get the server side value and pass it
in the javascript hidden field variable).
Here is the sample :
<script type="text/javascript">
function openNew(Callback) {
var popupURL = document.getElementById('<%=hdnURL.ClientID%>').value;
//L_Menu_BaseUrl + "/Lists/List1/NewForm.aspx";(don't use the variable when using IE11)
var options = { url: popupURL };
if (Callback) {
options.dialogReturnValueCallback = Function.createDelegate(null, CloseDialog);
}
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
return false;
}
function CloseDialog(dialogResult, returnValue) { //if user click on OK or Save
if (dialogResult == SP.UI.DialogResult.OK) {
//refresh parent page
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.RefreshPage', SP.UI.DialogResult.OK);
}
//if user click on close or Cancel
else if (dialogResult = SP.UI.DialogResult.cancel) {
// Do Nothing
}
}
<asp:HiddenField ID="hdnURL" runat="server" />
.cs File:
protected void Page_Load(object sender, EventArgs e)
{
string currentWeb = SPContext.Current.Web.Url;
hdnURL.Value = currentWeb + "/Lists/List1/NewForm.aspx";
Bind_Items();
}