replace server js files with local js for debugging - javascript

I have an application that has js file on the server, I want to be able to make changes in a local file and see how the web application responds. Someone pointed me to fiddler, but I am not sure how do I achieve that. If anyone knows any way I can achieve this, I would be really helpful. Also my js file doesnt show up in script but in network response.
Thanks in advance

Can you use fiddler web debugger to intercept and modify the script? I have used fiddler before to add debugger statements to 3rd party JavaScript. It was easy.
Download fiddler and use the menu options to break on a script response. Then you can edit the script in the lower box and continue.
I will get links and more details for you.

Related

Open network location in Javascript

Is there any way to open a file or a folder located on the network? I understand reasons Browsers dont allow that. And I know that I need to add extensions to Chrome and FireFox to get a network folder shown. When I meet these requirements and I have an href that looks like:
file://network volume/directory
then by clicking on it I get a folder open. Now I need to open it by clicking on a button. Is that even possible?
Thanks
Assuming you jumped all the hoops and completely unsecured your browser (which I did not, which makes this answer a guess rather then a solid answer), I suppose that javascript actions on window.location might work. e.g.
window.location.href = 'file://foo/bar/';
or the window.open API http://www.w3schools.com/jsref/met_win_open.asp
A side note, do check the HTML5's file APIs. They explicitely require that user picks the files explicitely and do not seem to allow what you require, but they are the endorsed file approach and if, by any chance, your requirements can be met by using them you'll save yourself from a world of pain and going against the flow... See http://www.html5rocks.com/en/tutorials/file/dndfiles/ for a good starter.
If I understand you correctly. You want to access a file on the local server.The following would work for you.
window.open("http://www.example.com");//opens a url
window.open("file://server/serverfolder/index.asp");// server side

File Protocol Ajax Request

I have made a project whose structure is like this
When I run my index.html from firefox, it is working fine.
But I open it with my chrome it is giving CORS error.
Now my problem is that chrome doesnot support file:// protocol ajax request & as I have distribute to my project to others I don't want other to run on firefox only.
Internally I am using ajax call in project, to load the resources. Can Somebody suggest how to bypass that ajax call to load resources?? Is there some solution or any third party js which can help me.
Note: Please don't suggest to use XAMPP, apache etc where I can put my project and run as localhost for chrome as I don't want user to force to download these to run my project. Please give other useful solution where I can do some change in code & it works for everyone.
Here are the links from which you could understand my problem better.
Ajax in Jquery does not work from local file
AJAX code do not run locally
AJAX request using jQuery does not work
Embed the data directly into the JavaScript or HTML and read it from there.
The data isn't going to be changing based on user input or the contents of a database, so having it in a separate "http" resource doesn't bring huge benefits.
If you want to store the data in XML to make it easier to edit in your development environment, then write a build tool to bundle it up into an embedded format before distributing.

Prevent users from reusing website source files (downloading is okay)

UPDATE:
Something's wrong with stackoverflow. It seems people couldn't read the first line of the question properly and they start preaching about "how websites can't be downloaded" which is not exactly the question. So here is the question in a more specific way:
How to get hosted server's IP address (or any other information which is unique to the hosted server) using jQuery. Googling doesn't help much.
Now, please don't start with "getting client's IP address" or "this can't be done". I know this is nearly impossible; but if someone can get me close to the idea, that'll do.
Oringinal Question:
I know users can download the source files if they can see it in their browser. What I am trying to do is stop them from reusing it. Like checking IP of hosted server and redirecting to the original domain if the files are hosted in a different server.
Using PHP (or any server programs) won't do as the end user will be getting the final html/css/js files.
Basically, I don't want anyone to download and host/reuse website files.
Thanks in advance.
Javascript is code, and can be obfuscated. This makes it so difficult to maintain that it's usually easier for the end user to re-write from scratch. Try Googling for "Javascript Obfuscator".
With HTML and CSS, it's pretty much open to the user. Not much you can do about that!
If you make website in PHP you will write some code that gets translated into end-html that user can view and download. So your source file in PHP is unreachable for end-user. Like in Wordpress your code could be only few rows and end html could be hundreds of rows long because it reads data from a database and puts it into html.
If you write scripts in javascript you can not protect it from downloading and reusing that.
This can't be helped. If the viewer can view your website he can download the front-end of the website.
If your worried about someone downloading your server-side scripts, you don't have to because server side cannot be downloaded through the front-end.

How to make AJAX work on local server using XAMPP or node.js

I am at my wit's end and I'm hoping someone can help.
I have been trying to get AJAX to work on a local server, but I don't know where to begin even with the most basic code. I have downloaded node.js and XAMPP and I have been looking online for tutorials on how to get even AJAX test sites to work.
If anybody knows of a step-by-step tutorial on how to get the most basic AJAX functions to work on node.js or XAMPP I would appreciate it so much. Everything I've found seems to assume the person reading already knows how to begin working with a local server to make the code work. I know what code I need to write from all the examples, I just don't know how to get it to work on XAMPP or node.js! Thank you.
is XAMPP working? can you access it via http://localhost?
AJAX is just javascript that can send requests without reloading the entire page. it doesn't need anything special to work.
however its important that localhost is working and keep note if you need to add a port to the end of the url to get it to work.
then add your html/php file into the htdocs folder of XAMPP and navigate to it using the localhost url.
In case you have Visual Studio installed. Click
File Menu
Open
Web site
Select the website folder
Hit F5 to run the app
First, you have to create your html file; do it in the "htdocs" folder of XAMPP, which is likely to have its folder on your C: hard drive path, unless you moved it elsewhere.
Secondly, start XAMPP Apache server. Now you can access your html web page via web browser at "localhost/yourwebpage.html".
Hope this help everyone!

how to view source code for javascript src

I apologize in advance if this question is not appropriate for this forum. I could not find answers from searches in Google or Stackexchange. Also, because the question was specific, I thought I might be acceptable.
Background:
The end purpose is to troubleshoot a server connection error where a client machine runs javascript. I'm trying to at least determine the source and destination network ports used for the communication attempt.
I know zero javascript but have some background in C++.
The client runs this html page:
<script type="text/javascript" language="javascript" src="com.vmware.vim.cimmonitor.gwt.CimUi.nocache.js"></script>
Is there a way to view the contents of the specific js file? I cannot tell if the js file is bundled locally in some kind of javascript library or resides somewhere in vmware.com
I've tried to directly enter the full js name into firefox, but got a server not found error.
Thanks.
Press F-12 to open the browser's debugger. Open the NETWORK section. Reload the page. It will show you a complete list of resources as they are loaded. You can click on any of these to look at the source and http header information.
Unless the js code is using websockets, communication is likely just http:// on port 80.
if you use the developer console in chrome/safari, you can view all loaded javascript in the resources tab.
you can also use netstat to see what active port connections you have.

Categories

Resources