سؤال

I am trying to add a click event to a link in SharePoint. The current href set by SharePoint is href="javascript:ClickOnce()". If I add the following code:

var saveNclose = document.getElementById("diidIOSaveItem");
saveNclose.href = "javascript:JSEPreSaveAction()";
alert(saveNclose.href);

The alert outputs the href I am trying to get, which is javascript:PreSaveAction() but when I look at it in the page it is still ClickOnce().

Why is the alert telling me the href is one thing and the source code and behavior says is another? Is there something causing SharePoints script to take priority over mine?

هل كانت مفيدة؟

المحلول 2

I was able to do this by adding a timer to add PreSaveAction() to the button 10 seconds after the page had finished loading.

نصائح أخرى

document.getElementById("diidIOSaveItem").setAttribute("href", "javascript:JSEPreSaveAction()");

alert( document.getElementById("diidIOSaveItem").getAttribute("href") );
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top