Can't load images with local js library - javascript

I'm developping an android application and I'm using local html files, therefore I use the js libraries and css's locally. The problem is that they refer to relative images on the web, I download them and try to refer them locally as well, but it does not work.
Any suggestions?

Related

Browsers load an broken version of CSS that's on the server, and not the original CSS

So I am building a website and having a problem. I have only 1 HTML file, 1 CSS file, and 1 very small javascript file. The directories are all correct, and the CSS amd javascript files are correctly linked in the HTML, but here's the problem:
When I put the files on the server and opened the website from my domain (daveyloper.com), the website is all janky. The dev tools on Chrome and Firefox show that the CSS file is different than the one I see on the server. For example, the CSS file on the server has more lines than the one in dev tools. Some styles are also altered, like my #logolink and #logoimg, as well as .project-slides p.
Another thing I noticed is that when I upload the HTML and CSS files on the server, both with filezilla and the cpanel, the size of the file changes, becomes a little bit smaller.
Also, it seems the problem is mainly related to media queries, as most things in desktop view work fine, but in mobile view which I made using media queries everything is broken.
So here are my questions:
Why is the CSS file that's loaded by the browsers altered from the one that's on the server?
Why does the CSS file load properly from my hard drive, but does the abovementioned when loaded from the server?
Is there anything I can do to fix this?
I am using infinityfree for hosting, and filezilla to load files on it, and VSCode as my IDE. I'm linking my current code below:
https://github.com/Lursmani/daveyloper.com
Any help would be appreciated. Sorry if the code there is all jank, it's my first time building a website and I started from scratch.
I found the problem. Cloudflare had a cached version of the website from yesterday and the browsers were loading that instead of the live website. I cleared Cloudflare's cache and it seems to be working fine now. Thank you for your help!

How to load local file in new tab?

I am working on angularjs java project. I won't to load local files of all file types (txt, pdf, image files etc.) from my system into new tab on click of button using javascript, angularjs or java code.
I able to load the content of the files but it is not displayed in correct format ie. I won't to load the file in similar format as they are placed on my system.
I would be thankful if anyone could help me in finding the solution.
You can't simply expect your browser to display the file as it is displayed in your local system.
If you try uploading a file and then viewing it, the browser will download the file and technically, you then view the file locally.
There are a few Cloud Storage options such as Box.com and Google Docs that have their own file explorer (that support limited file types). I don't think there is any free library available that does that as it requires quite an effort to support many file types for display in the browser.
This requirement can be achieved by following directive ng-bind-html in angular Js .
Kindly refer the examples and documentation which is given in Angular Js website
$sce is a service that provides Strict Contextual Escaping services to AngularJS.
Check this link for directive documentaion
For viewing pdf use ng-pdfviewer, include ng-pdfviewer.js as JavaScript file, along with pdf.js and pdf.compat.js.
Declare ngPDFViewer as dependency to your module.
You can now use the pdfviewer tag in your HTML source.
Click here for GitHub link for ng-pdfviewer
Use <img ng-src="image.jpg"/> for images

Accessing Js from file from outside an EAR/WAR

I have a requirement where a JS refernced by my web applications needs to reside on a location other than the context of the app. For eg. The deployed structure of my project looks like
myProj.ear/myProj.war/layout/thePageThatNeedsExternalJS.xhtml
this lives under $JBOSS_HOME/server/default/deploy.
Requirement states that theJavascript.js file should be present on the file system for eg. at
/home/amit/myJsFolder/theJavaScript.js
Now I tried referencing this JS using scr="file:///home/amit/myJsFolder/theJavaScript.js"
I also tried using "../../" path to try to point it to the right location but that does not seem to work either. I tried to see if the Js got linked by using the chrome developer tools and the js is not listed in the scripts section, but other scripts are for eg the Jquery script.
Is it even possible to link such a js inside a web app? Because I tried this on a single HTML page and it works.

Local file access in java script

I am using Pannellum, a free panoramic viewer which uses HTML5, and developed using JavaScript.
http://www.mpetroff.net/archives/2012/05/28/introducing-pannellum/
The application works well, if the image is on web, but if it is local (assume that I have a html file locally and I want to open a panoramic file locally). It doesn’t work.
Is there any way that I can address a file locally and let this application works? It seems that it is using three.js and loads image using image() control.
I need to be able to use this application to download local file when it is opened in local browser. I am aware that a JavaScript from a web site cannot open a local file, bit in this case, al files are local.
Have a look at this wiki:
https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally

Why isn't my javascript working on a local HTML file using UIWebView loadRequest:?

I have a script that generates a temporary HTML file that has links to external Javascript files that it requires to run.
<script src="file:///Users/raphaeldefranco/Library/Application Support/iPhone Simulator/User/Applications/BA9E724E-76BD-4F28-B224-54B4C73786D6/LogTen.app/Reports/Time by Year/../../Tools/PlotKit/Base.js" type="text/javascript"></script>
The links are absolute and they are to the right place (There is a CSS link as well that uses the same method and it works fine). I've been using the following, which finds images and CSS just fine but for some reason won't run the .js.
[webView loadRequest:requestObj];
I've tried changing the encoding of the files. I had a problem getting the CSS to work until the file was in unicode, but so far no luck. All the Script files are bundled with my project etc.
Thanks in advance!
You can't access things outside the application bundle directory. Just copy them in and access them without the path. They will be in a different location anyway when installed on the device.

Categories

Resources