in test server javascript in not loading IIS - javascript

I am deploying the Asp.net application on two different server test servers and a production server. in the production server, everything is fine but in the test server, JavaScript is not loading in chrome while in edge it's working fine. I have removed the content security policy header from the middleware but in vain.

This happens many times because when loading the script you need to update a version (otherwise it doesn't update the loading of the script), try adding like this:
<script src="myscripts.js#DataTime.Now"></script>
That way it will reload the script for you on every restart

Related

How to fix Google Analytics "analytics.js" net::ERR_FILE_NOT_FOUND?

The relevant line of the Google script is:
(window,document,'script','//www.google-analytics.com/analytics.js','ga');
I am running this particular file locally (as in, I double-click "index.html" on Windows Explorer and it opens in Chrome.
After about a minute of trying to load this file it fails with net::ERR_FILE_NOT_FOUND reported in the Developer Console.
I understand why this is happening, it is trying to load this as a local file. If I do this it works just fine:
(window,document,'script','www.google-analytics.com/analytics.js','ga');
In other words, I eliminated the //. This would work just as well:
(window,document,'script','http://www.google-analytics.com/analytics.js','ga');
Is going explicitly doing it this way to only track real websites?
If so, how are you dealing with this issue for local development?
I do run a VM with Ubuntu server for local development of more elaborate sites. In this case I was working on a single file landing page that I knocked out quickly and wanted to just test just as easily but ran into the browser hanging waiting for analytics.js
Is it safe to remove the // or add http: in general terms. I don't generally like to modify Google code unless I fully understand why they are doing things in a specific way and what the consequences of my actions might be.
Instead of viewing the file locally, run it through a local webserver. Two easy options are
XAMPP: http://portableapps.com/apps/development/xampp
Uniform Server: http://www.uniformserver.com/
Both require no installation. If you have Visual Studio or WebMatrix, you can also run it through Cassini or IISExpress.
It can be that you are using a VPN(Virtual private network) which analytics blocks. Try loading https://www.google-analytics.com/analytics.js
If id does not work try disabling the VPN and try again.
Or as someone else mentioned it could be that your AdBlock is blocking it.

How is a "l.js" file loading on my php page

I was checking for some load latency on a php page I am building.
I discovered some resources that I wasn't loading:
l.js
r.js
icp
s.gif
I disabled all css and js files (including jquery) in my page but still see these files loading. The s.gif is especially disturbing because the request has the URL of my php file on it and I really don't want that information out there. (I am running the server over https for security but don't want to have to put a user login on top of the server.
I am serving on OS X Server and using Safari as the debugger and load analyzer.
This issue did not show code that explaind where the resource requests were coming from. I started disabling browser extensions and that did the job. Apparently they were injecting resource requests with the downloaded pages.

Firefox Add-on SDK reload extension only upon restart

I'm currently having an issue with an extension I'm developing using the Firefox Add-on SDK. For some basic context, the extension executes content scripts using the page-mod api in the sdk. On each of the content scripts some additional javascript is injected into the page itself (we'll call them page scripts). In order to do some complex tasks, the javascript injected into the page can communicate with the content script and which will then in turn make requests to the background process of the extension. Due to the complexity of the extension, when it is auto-updated, it is possible to get into a state where multiple page-scripts running the same code are running on the given content-script.
What I'm wondering is if it's possible for extensions built using the Add-on SDK can be forced to update itself only upon restart. This would mean that the extension won't get reloaded even if the auto-update occurs until a user restarts their Firefox Browser.
If this is not possible, any other solutions would be great.
Though I agree with #Noitidart's comment, you can choose to inject your content scripts from main.js only on restart like so:
const { loadReason } = require('sdk/self');
if (loadReason==='startup') {
//Inject the scripts
}
You'll have to make sure that your old version's content scripts can communicate with the new background scripts without breaking, which will be a pain to test. See here for the other load reasons.

How to load javascript not present in localhost domain in chrome?

I am running a tomcat server and my localhost base domain is :
C:/apache/webapps/ROOT/
My webpage is also present here.
However the javascripts are present in an external location.
D:/something/something
And i am importing them the following way
<script src="D:/something/something/js1.js"></script>
In IE the page loads fine and able to locate the scripts, however with chrome it fails.
On debugging I see that chrome tries to append the following:
http://localhost:8080/D:/something/something
How do i get it to work on chrome without copying the scripts to base location?
For doing anything useful from within the JS code, you'll most likely have to obey the same origin policy. This means you'll have to configure your Tomcat so that it serves the scripts, too.
If you really insist on reading the scripts from local files, that's what file:// URLs do.
You can't do this because you will search for D:/something/something/js1.js in the user/client computer.
You can do it calling (read and print) the file via PHP (D:/something/something/js1.js.php) or any other server side programming language or installing a webserver in your external location to call the file via URL like myCDN.mydomain.com.
EDIT: If you will only work in localhost, use #Pointy and #Konstantin K solutions :)

Javascript fullcalendar prod server vs dev machine issue

<div id='calendar'></div>
Is the html tag that the fullcalendar uses to insert a calendar and do its magic. It's a great tool, but something weird is happening.
My calendar is created with events from the DB and all that stuff works well. Here's the issue...
Calendar on 2 pages - both work great on dev workstation.
Deployment - works on one page, but not on the other. The calendar div gets populated with some complex tables etc for rendering. Except this doesn't happen - ONLY on one page, ONLY on the production server - same browser. All the db stuff is there, pages coming back are identical other than the table stuff that gets inserted on my dev machine, but not when server from production. But again, the same control works just fine from prod on another page - stumped! Web server is IIS 7
Any thoughts or even wild speculations most welcome!!
Just to make it an official answer...
Commonly when something doesn't render in either a development or production settings but does in the other environment you're experiencing an absent resource. This is usually something along the lines of requiring the following:
<script type="text/javascript" src="..path/to/script.js"></script>
Since one location has the file in that location and the other doesn't, you can run in to scenarios where it works in one spot but not the other.
Easiest method to confirm this is to open the debugger in your favorite browser and use the "networking" section to determine if all the resources are loading correctly (and are resolved). Otherwise, chances are the page that's not working is getting a 404 (or other error) when trying to retrieve the file it needs and thus the page fails to operate.

Categories

Resources