Javascript – How to add jQuery from a Javascript file

Lignes de code HTML

When you create a javascript file, you may want to make sure you can use jQuery. To avoid having it twice and maybe introducing incompatibilities, just add this at the beginning of the javascript file: if (typeof jQuery ‘undefined’) var script – document.createElement (‘script’); script.src – ‘http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js’; script.type – ‘text/javascript’; document.getElementsByTagName (‘head’)[0].appendChild (script); }

Javascript – Iframe – the address where the iframe is located

MacBook avec code sur un bureau

For security reasons, you can’t directly reach the page outside the iframe from inside it. However, we can retrieve information from the browser. To retrieve the parent’s address, i.e. the URL of the page where the iframe is added, just write this: <script type=”text/javascript”> var url (window.location!) – window.parent.location)? document.referrer: document.location; alert (url); </script> This … Read more