0

On a site page, I have a Calendar CEWP and the following JS in a script editor. The calendar events pop up in a modal in IE but they do not in Chrome. Can anyone identify why it is not working in Chrome? thanks so much.

<script src="https://code.jquery.com/jquery-3.6.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
    $("a[href*='DispForm.aspx']").each(function () {
        $(this).attr("onclick", "openDialog('" + $(this).text() + "','" + $(this).attr("href") + "')");
        $(this).attr("href", "javascript:void(0)");
        $(this).removeAttr("target");
    });
});

function openDialog(title, url) {
    var options = {
        title: "Calendar - " + title,
        autoSize:true,
        url: url
    };
    ExecuteOrDelayUntilScriptLoaded(function () { 
        SP.UI.ModalDialog.showModalDialog(options);
    }, "sp.js") 
}
</script>
5
  • Try setting href attibute to "#". Let me know if this works for you. Jul 20 at 16:37
  • Hi, I am just now seeing this. Set it to # instead of to DispForm.aspx?
    – seaandtea
    Jul 28 at 10:31
  • That did not work for me unfortunately.
    – seaandtea
    Jul 28 at 10:46
  • Try setting href attribute to "#" instead of "javascript:void(0)" at line $(this).attr("href", "javascript:void(0)");. Jul 28 at 11:02
  • that did not work either :/ it is still navigating to a the full display form page.
    – seaandtea
    Jul 28 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.