Where do I find the code behind a dynamically generated .aspx file - javascript

I'm trying to debug a dynamically generated aspx file, which is throwing an error. I've been unable to find where the dynamic code is generated from. When debugging the application, I get an error from the line
_dialog.dialog('close');
as there is no dialog to be closed. I'm looking to find where I can change this in the static code, but don't know how to trace dynamic code. The call stack goes back only one function to JScript global code.
Thanks.

If you are using VS2012+, use the project window as it shows the actual generated code (during runtime). Also don't dismiss the new IE11 developer tools (F12). You can get loads of information on where the source is coming from.

Related

find javascript changing HTML

First off, I'm not a developer, but a site owner running wordpress. my site has some Amazon affiliate URLS. What is happening is some rogue javascript is running and changing the referral ID's of the HTML code only from a google search specifically (If I load a page directly the HTML doesn't change). Basically I'm trying to figure out how to locate it, I figure that by looking at the html section I can trace what javascript is changing the HTML? With that information maybe I can help find it or pass that on to the hosting company to remove the file.
For example:
in the website shows : https://amazon.com/49684095/?tag=properamazontag
the javascript runs and changes to: https://amazon.com/49684095/?tag=douchebagscammercode
I hope it makes sense.
I have disabled javascript in the browser and confirm that the HTML code doesn't change, so I know it's a javascript issue.
For anyone looking at this with the same issue, what I did was follow this thread Find javascript that is changing DOM element. I went through all the JS changes looking for odd code not associated with a plugin file or theme.
once I found the code, I used a plugin called string locator and searched "everything under WP-content" for the first part of the bad code. From the plugin shows the location of the code (a JS file was added to the theme template) and I then used the same technique to search for the names JS file (in this case called theme.js) and found a php line in the functions.php file that had to be deleted along with the file.

Jupyter NB prevents Javascript execution from taking effect

I am running a jupyter notebook on a local server and spent the entire last day trying to get a javascript library for charting to run. It's called Dygraph (http://dygraphs.com/). Outside of the jupyter notebook everything is working as it should, but if I want to use the library inside a notebook, then things get messy. Even displaying a simple html file, which uses the library and works just fine outside jupyter, is not working when viewed via the server. All resources are in the right place and seem to get executed, just without having a lasting effect.
I know that the script is executed, because I appended "console.log('okay')" to the local source file (http://dygraphs.com/2.1.0/dygraph.min.js) and "okay" is in fact showing up in the browser console.
I executed the script in the following ways (none of which were effective):
By using IPython to paste a script tag, which links to the resource (src="...")
By reading the content of the script using python and using IPython to execute the javascript directly
The most obvious way: by manually copy-pasting the content of
dygraph.min.js into the console
If I execute 3) on any other site, then I can successfully run the following simple statement:
console.log(Dygraph)
However when I am inside the notebook and try the same, I instead just get:
ReferenceError: Dygraph is not defined
How is this possible and how to fix it?
PS:
I also tried using the python wrapper PyDyGraphs (https://github.com/DayStarEngineering/PyDyGraphs). The example code of the github page throws the same ReferenceError and the graph is not displayed correctly (instead there is just the empty div).

How to debug js loaded in ajax request in Chrome DevTools

Actually I am a big fan of Google Chrome DevTools but it is very vast area for learning. I don't know much about it. I know how to out debug point, searching (Ctrl+Alt+F) and debugging, etc. basic things.
But in one of my project (its in asp.net MVC), it is requesting different views in Ajax request and in that views there are some js loading. I want to debug them but I am not able to. Actually I don't know where can I see them - especially the JS which is load after ajax call (its not inline javascript but a separate js files).
A workaround I found is - if I put 1 "debugger;" in that js file then it opens with some VM3012 or similar name with different numbers. Then only I can see the files. But I can not put debugger when I publish the code.
Any body knows then please help.
Thanks a lot for reading.
EDIT
as per first answer, I have tried but I can see that option "Open in Source panel" for normal JS file. But in my case my request is passing some query string to the js file like assets/components/utility/mycustom.js?_=1528282662460 and I am not able to see that option for such request. This help is appreciated but need more.
I know it's been 3 years but...
You can name the piece of javascript code inside the dynamic loaded file by adding the following above the code:
//# sourceURL=my-file-name.js
By doing it, that piece of javascript will be available in the file tree of the source panel and can also be found by the DevTools' CTRL+P shortcut.
Go to the network tab of the dev tools. You can filter by js files to help you find the file you need. Right click on the file you want and select Open in sources panel. You should now be able to put the breakpoint where you like as you are used to.

Adding JQuery/Javascript Files to Project

I have a project I am working on at work that is ASP.NET in TFS. I have checked out the solution and have made some adjustments to the code behind with no issues. When I try to add JQuery and a Javascript file to the project, it does it fine in Visual Studio 2012. But when rebuilding and running it won't execute the javascript code. It's like it ignores it. When I put breakpoints in the Javascript file I get the message 'The breakpoint will not currently be hit, no symbols have been loaded for this document'. I simply cannot get the web page to acknowlegde either the JS file, or the JQuery file.
(And yes, I have scoured StackOverflow.com and tried all the suggestions mentioned)
Any suggestions appreciated!

Javascript: How can I find where String.format() is declared in my web application?

I have tried in vain to locate where String.format() is declared in my web app. On some pages, it works. On others, it doesn't. Sometimes, intellisense will show it even after I've commented out every .js reference in the HEAD of my document, but, when I run the page, I get the JS error:
Error: Object doesn't support property or method 'format'
I want to know where it is because I want to use it in another one of my pages. Is there a specific syntax string I can search the entire solution for?
Try in the client code. Open the browser (I prefer IE9+), F12 to open Developer Tools, Script tab and in the right you have a search box.
Type your search criteria there in a page where format is already available.
It will open the file and show the code. In the top of the file you can see its url.
Instead of using search, as suggested by others, just set a breakpoint at one of the calls. Then move into the call and voila, you're inside the file where it's defined.
(for example using Google Chrome inspector)

Categories

Resources