using JavaScript from another page - javascript

I found the following Javascript effect to be interesting and wanted to use it on my webpage as background.
http://www.chiptune.com/starfield/starfield.html
I saved the html page on to my computer and tried to run it locally, but all it render is a blank black page.
The page doesn't seem to use any external files other than the adsense .js'es.
Then why is running on my browse directly from the their website but not locally from my computer.
Note - I ran it as file:///home/anirudh/fest/stars/Starfield.html and not from local server. Is that why it is not running?

Because the 2 adsense js files are missing when you run locally, the rest of the javascript does not execute.
Removing references to the 2 js files fixes the issue as tested just now by me :)

Related

why doesn't my live server work in visual studio code?

My live server on visual studio keeps opening an old html file when i try to open my current one. Ive tried reinstalling the extension but its the same problem. Can anyone help please
i cannot have two project folders with an html file running through the live server. Only one html file can be streamed at one time other wise when trying to stream the second, it will stream the first (Like the issue i was having)
I was having the same problem but later on I find out that, I renamed my project folder while my server was still loading the same project but with the previous folder name so I changed the link to my new folder folder name and it worked for me.
I have live server will simply not work if there was an error in JavaScript file.
Even if you do an alert in the beginning of JavaScript file (for test purposes) but at the end of the file re-define a variable which was already defined before, this error will render liver server not working.
The html page will not respond as well.
Solution is to go to developer tools (F12), see the errors on console, fix them and save and the live server would be back in action! At least that was the case with me.
I had the same issue, sometimes it was an error on the console, or keep showing an old HTML, tried everything, deleting cookies, reinstalling everything and nothing worked,
Eventually, it worked with a hard refresh, what it really worked was to
Go to ---> vs code settings ----> extensions ---> live server config set as chrome private. So far no more errors!
The liveserver extension serves static pages like html files and it does not load javascript or typescript files. You need to setup a server yourself for example in react you use webpack to configure your local server and your app runs on a localhost:port. In a nutshell, you need to write a script for node to run your js files. And you won't need liveserver after that.

Issue with uploading website to hosting

I tried uploading my website to the free 000webhosting service. My website loads fine locally, but when uploading it through FileZilla and reloading the page I get an error that says "The jQuery library must be included before the smoothscroll.js file. The plugin will not work properly."
I have a smooth scrolling javascript file and some jquery in my code that I got from somebody else. Does anybody have any idea why my website loads fine locally, but the smooth scrolling doesn't load when uploading my site to a host? And yes, the jquery is before the javascript.
Try to check for your problem:
The files don't exist on the server at all at that path
You moved the files but didn't change the path in index.html
You changed the path in index.html but didn't move the files there
Try checking the files of the particular plugin on the hosting server.
There must be some files that are missing or not uploaded completely.

Are you able to recreate this site on local machine?

Seems obvious to recreate a site -- just copy the files over and it should work. But it doesn't for me. I've tried copying down all the scripts, images, and .html files but it doesn't seem to be displaying anything. All the paths are right btw, and still all black.
This is the website.
Advice?
try to run it for local web server like apache
if you are using windows try use wamp server
Please Checkout this link for how to run three.js on local machine
https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally

jQuery FancyBox plugin Quick Inquiry

I have a quick question on the FancyBox plugin. I don't need help on code, I just need help understanding one thing.
I have been designing the website in NetBeans and every now and then I will use Chrome and refresh the page to see my progress. The site isn't online, and I am just checking via my laptop and Chrome.
I have videos that I want to open in an iframe class, but they don't seem to work. The demo file that came with the downloaded pack states "Will not run from your local computer, requires a server to run." Is this the reason why the youtube videos don't show? Do I need to actually get hosted to see if they work? Can I bypass this by getting the video files themselves and putting them in my root folder?
If you are ok with terminal/prompt you can cd into that folder and run this to get a simple server running which might help
In terminal:
python -m SimpleHTTPServer

local file access in Chrome

I'm encountering an issue with some local web prototyping;
I've been working on a single page which access files on my C:/ by starting my Chrome with --allow-file-access-from-files.
This is great, I've got my first page working successfully and it loads in my .js,.css files etc as expected.
However, when I click the link to proceed to the next page, the HTML loads, but none of the styles, javascript (or even images) load.
I'm receiving 'Failed to load resource' errors in the console, despite the file:// url pointing to the correct location.
Is there any way around this issue?
In lieu of a solution, some advice: Set up a web server on your computer for testing. Developing in an environment that's similar to a "production" environment, as opposed to working around the quirks of local file access, will save you quite a bit of time in the long run.
There are a number of tools that will help you set up a development web server; XAMPP is a popular one.

Categories