How to get the url from Chrome Devtools

Asked

Viewed 127 times

1

I have the following code:

function AbreModalEnvioRelatorioDiligencia(id, idProcesso) {
    debugger
    $("#myModal").load("..\..\_ComunicaDiligencia?idProcesso=" + idProcesso + "&idInformacao=" + id, //+ id,
        function () {
            $("#myModal").modal();
        });
}

Is there any way to know which url results from . load()?

  • Maybe save it to a variable and in devtools get its value?

  • @Andersoncarloswoss was what I was thinking, but how could I do that?

  • Try to open the modal, right click on it, and say "View source code" http://prntscr.com/ongkcr will open a new tab in Chrome with the source URL http://prntscr.com/ongkvy is a manual procedure, but it sometimes helps you to get the generated modal URL somehow...

  • 1

    Nice, I’ll try it, I didn’t know I could get the url like this! Thanks for the help @hugocsl :)

1 answer

3

Let’s abstract your problem for a minimal, complete, verifiable example, with no external dependencies.

console.log(`/questions/${Math.floor(Math.random()*1e6)}`)

Basically a random Stack Overflow URL will be displayed in Portuguese, without validating it whether it exists or not.

The goal is, through the debugger, check the value that will be passed as parameter to the function, then you just save this value in a variable before using the debugger and later access it via Console.

const url = `/questions/${Math.floor(Math.random()*1e6)}`
debugger
console.log(url)

See how it would look in the browser:

inserir a descrição da imagem aqui

In your case, it would be something like

function AbreModalEnvioRelatorioDiligencia(id, idProcesso) {
  const url = "..\..\_ComunicaDiligencia?idProcesso=" + idProcesso + "&idInformacao=" + id;
  debugger;
  $("#myModal").load(url, function () {
    $("#myModal").modal();
  });
}
  • Nice, it’s a good scene! But having $("#Mymodal"). load("../../{accao}/{parametros}"), how would you get the whole url?

  • @Araújo I put how it would look for your case... is exactly the same logic I presented earlier.

  • Nice, I’ll try to see if it works, thanks for the help :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.