Posts

Showing posts with the label JavaScript

Right way to add CSS and JavaScript to SharePoint App Pages and Master-Pages

In SharePoint-Hosted App, there is a special way to embed your JavaScript and CSS. Adding JavaScript: To add JavaScript that resides in the "layouts\15" folder, just specify the file name: < SharePoint:ScriptLink name=" sp.core.js " runat="server" LoadAfterUI="true" Localizable="false" /> To Add JavaScript that resides in your app, for example in "Scripts" folder of your SharePoint-Hosted App: <SharePoint:ScriptLink name=" ~site/Scripts/App.js " runat="server" OnDemand="false" LoadAfterUI="true" Localizable="false"></SharePoint:ScriptLink> Adding CSS: To add CSS to a SharePoint-Hosted App, you need to know how SharePoint works, its a bit different form that way JavaScript is embedded in the app. Initially I thought, I could use "<SharePoint:CssLink" just the way I used "<SharePoint:ScriptLink", but it wasn't true. Sha...

Enumerate through all href using jQuery – Update all URLs on page using jQuery

I first tried doing the following: $.each($('a'), function (index, value) {                 alert($('a')[index]);             }); Well, the above code works and gives you the absolute URLs, however, you can’t make any change to the anchor tag itself, which is why most likely you are enumerating. Therefore, I rewrote the code as follows: $('a').each(function () {    alert($(this).attr('href')); }); You can clearly see, this is indeed the right way to go!