How to properly reference local resources in HTML?

A leading slash tells the browser to start at the root directory. If you don’t have the leading slash, you’re referencing from the current directory. If you add two dots before the leading slash, it means you’re referencing the parent of the current directory. Take the following folder structure notice: the ROOT checkmark is green, … Read more

How to get the file-path of the currently executing javascript code

Within the script: var scripts = document.getElementsByTagName(“script”), src = scripts[scripts.length-1].src; This works because the browser loads and executes scripts in order, so while your script is executing, the document it was included in is sure to have your script element as the last one on the page. This code of course must be ‘global’ to … Read more

Rotate an image in image source in html

If your rotation angles are fairly uniform, you can use CSS: <img id=”image_canv” src=”https://stackoverflow.com/image.png” class=”rotate90″> CSS: .rotate90 { -webkit-transform: rotate(90deg); -moz-transform: rotate(90deg); -o-transform: rotate(90deg); -ms-transform: rotate(90deg); transform: rotate(90deg); } Otherwise, you can do this by setting a data attribute in your HTML, then using Javascript to add the necessary styling: <img id=”image_canv” src=”https://stackoverflow.com/image.png” data-rotate=”90″> Sample … Read more

Why can’t I do ?

It would be a security vulnerability if the client could request local file system files and then use JavaScript to figure out what’s in them. The only way around this is to build an extension in a browser. Firefox extensions and IE extensions can access local resources. Chrome is much more restrictive.