Hi can someone help me in putting up a anchor tag in SherePoint custom publishing master page. Actually I want to open a site page on click on this anchor tag, this site page will be in the top level site collection under "Pages" gallery. I tried to put a anchor and on click event used "OpenNewFormUrls1()" function to be called which is defined in the script block in the same master page as :
<script type="text/javascript>"
SP.SOD.executeOrDelayUntilScriptLoaded(OpenNewFormUrls1, 'SP.js');
function OpenNewFormUrls1() {
var context= SP.ClientContext.get_current();
var site=context.get_site();
context.executeQueryAsync(Function.createDelegate(this,this.onSuccess), Function.createDelegate(this, this.onFailure));
context.load(site);
var serverRelativeURL=site.get_serverRelativeUrl();
ULS18u: ;
var options = { width: 500, height: 500 };
SP.UI.ModalDialog.commonModalDialogOpen(serverRelativeURL + "/Pages/openNew.aspx", options, null, null);
}
function onSuccess(sender, args) {
}
function onFailure(sender, args) {
}
</script>
After these changes the javascript errors start appearing, and on first click in the anchor tag no model dialog open up, whereas 2nd and afterwards click on the anchor tag open up the model dialog with the page, this happens for each new site visit within the site collection. The error message I am getting is as follows :
Message: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
URI: http://sp2010/_layouts/sp.runtime.debug.js?rev=f2An00kVlALdMLzcBc1cug%3D%3D
Can anyone help me how can I achieve this ? and what I am missing here ? Kindly help.