Sirve, por ejemplo, para cuando queremos probar nuestro código javascript en JQuery pero la página no tiene la librería cargada. Ejecutamos este código primero en la consola del navegador y la cargará: (function(){ var newscript = document.createElement('script'); newscript.type = 'text/javascript'; newscript.async = true; newscript.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'; (document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(newscript); })();
Categoría: Javascript
Crear notificaciones nativas de SharePoint en código cliente
Crear notificación propia de SharePoint: var notifyId = ''; notifyId = SP.UI.Notify.addNotification("Hello World!", true); El primer parametro es HTML (podemos personalizarlo). El segundo parametro es para que desaparezca: "true" hará que se mantenga hasta que clickemos sobre él, "false" hará que desaparezca al cabo de unos segundos. notifyId tendrá el identificador, que nos servirá para …
Sigue leyendo Crear notificaciones nativas de SharePoint en código cliente
Disable input ENTER key in Chrome, FireFox, IE (including IE8), etc. by Javascript & JQuery
In order to disable the ENTER key in your textbox type input, you have to add the 'onkeydown' attribute and call a javascript function that checks the key and avoid to submit the form when you press ENTER key. Input example <input name="myName" type="text" value="Search" onclick="eraseInitialText(this);" onkeydown="disableEnter();"> Javascript function function disableEnter() { var key = …
Add DIV dynamically with JQuery
You can add new div inside your web page by jquery always you want. You've to add the following code in your javascript function: $("#myExistentDiv").append("<div id='MyNewDiv'>This is my dynamic DIV</div>"); In this case, you're adding the div "MyNewDiv" inside your div with ID "myExistentDiv", just at the end of it. You can read more in …
Remove HREF attribute from any link with JQuery
You can remove any href that contains specific text inside the link. If you want to remove the link to any page that contains "DispForm" you can do it like this: $('a[href*="DispForm"]').removeAttr("href"); '*=' means 'Contains', but you can use anything you need: *= Contains = Equal != Not equal ^= Starts With $= Ends With
Hide «div» that contains a specific «div» in one of its children (at any level)
We want to hide "Level1" div that contains inside any "Level3" div in this code: <div class="level1"> Level 1A <div class="level2"> Level 2A <div class="level3"> Level 3A </div> </div> </div> <div class="level1"> Level1B <div class="level2"> Level2B </div> </div> We can do it by JQuery, once the page is loaded, that way: <script type="text/javascript"> $(document).ready(function(){ hideLevelOne(); …
Sigue leyendo Hide «div» that contains a specific «div» in one of its children (at any level)
Avoid ENTER in ASP TextBox (Javascript)
In order to avoid ENTER key in your asp:TextBox you've to add onkeydown event and control it, like this: <asp:TextBox ID="myTextBox" runat="server" onkeydown="return (event.keyCode != 13);"></asp:TextBox>
Javascript: Redirect to Main Site Page
<script language="javascript" type="text/javascript"> document.location.href=document.location.protocol + '//' + document.location.host </script>
Hide Elements List in ‘Details View’ and See Only its Properties in SharePoint
If you want to use the details view on a list or library and you don't want to see the list of elements (maybe you need to show only one item, or you're going to select that item on another webpart) you can hide it doing the following: 1. Edit Page. 2. Create a new …
Sigue leyendo Hide Elements List in ‘Details View’ and See Only its Properties in SharePoint
Pasar y Obtener Parámetros de la URL
Para pasar parámetros a través de la URL nos basta con añadir un "?" al final e ir insertando los parámetros que queramos con el patrón "nombre=valor" y separados por un "&", quedando del siguiente modo: Javascript: var URL = 'myweb.aspx?param1=1¶m2=2¶m3=3'; C#: String URL = "myweb.aspx?param1=1¶m2=2¶m3=3"; Si lo que queremos es obtener estos parámetros posteriormente, …