chrome dev tools: find which script fired JS event/error - javascript

the chrome dev tool gives me a error. actually i'm trying to get an http ressource from an https webpage :
i don't know where these files are called to change the target. i guess we can know with the chrome dev tool but can't find how. i would like to know which file is firing the call, which line... (if i get only the filename, it's fine)
someone can help ?

The blue box in the picture below represents the link to the exact line that caused the error. The format is filename:XX, where filename is the name of the file where the script originated, and XX is the line of code within that file.
Click the link to see that line of code in the Sources panel. If the file is minified, click the Format button to pretty-print it.

Related

how to navigate to the source file when debugging js in google chrome

I am using the google chrome to debugging the javascript source file, now I could debbugging the output js file, but the output js file is not human friendly readable. It looks like this:
from the google chrome console, I can see the call stack, and the google chrome tips shows that the source map are avaliable. But how to navigate the the js source file with current debugging line? I already type command + P in macOS but just shows the source files, I did not know which line should to navigate. the call stack only show the output js file line number.
Next to the "Page" tab (you can make the side bar bigger or click on those two arrows, there you will find the "Filesystem tab". If you add the corresponding folder to the workspace you will be able to edit and save those files.
Here's an article that explains it in details using a python server.
(note that you can use any local server you'd like)
(note that it won't work with local files url like file:///)
If you are trying to debug your current JS file at line 23487, steps would be to-
Load URL.
Open chrome debugger tools.
Put debug point on desired line.
Reload the URL, the debugger will pause at debug point.
You can watch below video for this, specifically #10:40 timestamp.
https://www.youtube.com/watch?v=WmVEddplwbo

URL Parameters are not processed when opening in MS Edge

Okay, here's a weird issue for you guy sand gals.
I'm using a window.open tag in JS to open a .cfm file that will open in Excel (Report), however, the appended URL variable appears to change. It seems that the ? gets changed to an _ and thus the browser thinks its a text file and not a web page. Any Ideas??
window.open("amal_reports/rpt_change_indicator_notes.cfm?batch="+selBatch);
The URL should be
http://example.com/amal_reports/rpt_change_indicator_notes.cfm?batch=1160 but when the browser asks what do with the file it says
rpt_change_indicator_notes_cfm_batch=1160 and wants to open a text
file.
If I call the report directly in the URL without the form or JS stuff the same thing happens, conversely, if I remove the URl variable (?batch=1160) the report opens in Excel as expected but no data is populated because the batch number is missing.
So, to summarize, the browser is changing my .cfm link from js or directly in the browser to _cfm and thus it won't open in Excel as expected.
Okay, developer error! It looks as though checking the developers tool (F12) based upon theGleep suggestion, I found that my page was missing or couldn't find a variable. Once that was corrected the report open as expected.

How to set breakpoint in Chrome for when flash video is loaded?

In the Chrome debugger's 'Network' tab, the 'Other' sub-tab shows a .flv Flash file being played. I'm trying to figure out exactly where/how that .flv URL is being generated, but I've looked through the JS for the site and can't figure out where it comes from.
Is there a way to set a breakpoint for when that .flv file starts getting streamed/played so that I can figure out how it's URL is being put constructed?
The request headers for the flv file in the Chrome debugger show X-Requested-With:ShockwaveFlash/24.0.0.194. So the request comes from Flash rather than from a JS file I think.
Or any other ways to figure it out?
Either the embedded SWF (Flash) app has specific code to construct the url (then method is unknowable) or else the app is reading the url from somewhere like a JSON or XML text file.
It could also construct by reading the text within an HTML / JS file. Third possibility is that PHP is involved in generating a link. So check the Network tab for such things (xml, json,php files which you open in a "new tab" to read).
Was there no flv found when you word-search the source of html or JS?... If all else fails then provide a testable link.
PS: To answer your Question : There's no loader breakpoints / load pausing in Chrome.
On Network tab you have multiple columns. One of them it's called Initiator. If' is missing, right click on any column and a dropdown with all columns available will appear. Check Initiator column.
That column should tell you what you need to find out.

How do I debug a dynamically loaded resource in Chrome?

I hit
Ctrl Shift J to bring up the Debugger.
I then went to the source tab.
The source tab states that you should hit Ctrl O to open a file. However, the only source it pulls up is the index.htm page and one statically loaded file.
I want to step through a dynamically loaded file.
That is a file that I called via ajax and then appended to the DOM.
Is there a way to do this in Chrome?
Ctrl + Shift + C in chrome.
Go To Source tab in the Chrome inspector that comes up, put a breakpoint on any file and line that you want to debug.
Reload the page and debug
Depending on the type of file, you should be able to use this developer.chrome.com/devtools/docs/javascript-debugging
Note that whilst the documentation says the source map should be of the format //#, this didn't work for me for an injected HTML file with JS in it, but when I changed it to //#, then it worked and I could see the file listed in inspector (under the "domain" '(no domain)').

I can't open JS files in Windows from Filezilla

I logged in to my FTP from Filezilla and tried to open a JS file, and it gave me the following error:
Script: C:/.../slider.js
Line: 1
Char: 1
Error: 'document' is undefined
Code: 800A1391
Source: Microsoft JScript runtime error
I have jQuery linked to the .php file as well...'document' comes from:
$(document).ready(function() {
//Code is here...
});
I tried downloading the file and opening it, I tried removing the $(document).ready();, I tried removing jquery (which by the way, when I opened the jQuery file it gave me the same almost the same error). Any help is appreciated. Thanks!
EDIT:
One of the tags for this post was "asp.net", but to be honest I don't even know if it is related to asp.net...
I had the same issue and fixed it by doing the following in Filezilla:
Go to Edit > Settings
Go to the 'File editing' section
Under 'Default Editor': Ensure that Notepad++ is selected as your custom editor
Change the radio button from 'Use filetype associations if available' to 'Always use default editor'
You say that you're right clicking and clicking "View/Edit", and it throws that error.
The error is occurring because Windows is executing the script, and the script has a problem (because it relies on another script being loaded).
So although you may be clicking "View/Edit", and expecting that this will open the file in Notepad++, what it is actually doing is assuming that "View" means "Run the script".
Clearly, Notepad++ is not the default action for this file type, or at least it isn't according to Filezilla. Maybe the default action isn't actually set the way you think it is, or maybe it's Filezilla that isn't respecting your default action.
The solutions:
If Filezilla has an option "Open with..." that allows you to pick the program to open the file with, then use that and select Notepad++ manually. Even better, if it has the option to then make that the default, then tick it, and the problem should be solved permanently.
Alternatively, just download the file to your local machine before trying to open it.
I got this working in FileZilla by doing the following: -
Edit -> Settings
File editing -> Use custom editor [file path to notepad ++] then
|___File editing -> Filetype associations
Adding the line -> js "C:\Program Files (x86)\Notepad++\notepad++.exe"
Click OK to save changes
This will stop windows script host from attempting to run the file and open in notepad++.
While the question has effectively been identified previously in the post I hope that someone finds this 'how-to' useful.
This is not a programming problem. It's a file association problem - Windows is trying to execute your .js file instead of opening it in an Editor.
See this question on SuperUser: running-javascript-files-js
There's also some explanation of the error here.
Check your file associations again. Try restarting your machine. You will get more help if you ask this type of a question on SuperUser.
It's worked for me after adding the file association.
Edit -> Settings
File Editing -> Select Use filetype association if available checkbox.
Select Filetype Associations -> add association here
js "C:\Program Files\Sublime Text 3\sublime_text.exe"
OK
Note: change association according to your text editor application.
Just follow these steps. It is an easy one to do. Change the default file type for opening the js files.
Edit -> Settings
File editing -> Filetype associations
Adding the line -> js "C:\Program Files(x86)\Notepad++\notepad++.exe"
That's it. Finally, Click OK to save changes.
It will work afterwards.

Categories