Donnerstag, 10. Februar 2011

Javascript load from different domain

Because of the same origin policy you can not load Javascript from a different domain. However this only applies to AJAX requests. If you add a HTML script tag to a webside the browser loads and executes it:

javascript:(s=(d=document).createElement("script")).src="http://google.de"; void(d.body.appendChild(s))


With the "javascript:" in front, you can execute it on any webpage. Just copy it in your browsers address bar and press enter. With this you can add new features to other pages. A function to delete all entries from facebooks pinboard or studivz would be nice. To make it look nice, you can add your script as bookmarklet to your browsers bookmarks.

Keine Kommentare: