function inIframe () { try { return window.self !== window.top; } catch (e) { return true; } }
Etiqueta: javascript
Cargar JQuery en el navegador de forma dinamica
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); })();
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
SharePoint 2013: Create JS File From HTML Display Template
When you create a custom Display Template and you deploy it, you can see the HTML uploaded, but you can't see its JS (created automatically in theory). Problem: You don't have the correspondent JS of your HTML Display Template Solution: 1. Access to your Site with SharePoint Designer 2. Go To: All Files -> _catalogs …
Sigue leyendo SharePoint 2013: Create JS File From HTML Display Template
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
Javascript: Redirect to Main Site Page
<script language="javascript" type="text/javascript"> document.location.href=document.location.protocol + '//' + document.location.host </script>
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, …
Evitar PostBack al Llamar una Función Javascript Desde un Botón
Cuando presionamos un botón, primero se ejecuta el OnClientClick, que es el que ejecuta la función Javascript que nosotros hayamos asignado. Si el resultado de esta ejecución es true, a continuación se ejecuta el OnClick, que esta en servidor y es el que provoca el postback. Para evitar esto (y que por lo tanto no …
Sigue leyendo Evitar PostBack al Llamar una Función Javascript Desde un Botón