how to get javascript console request url

Asked

Viewed 690 times

2

Guys I need to get the url of a get from the console I want to know this because I have an iframe that I need to get the url from it so that in the url there is a random variable that keeps changing whenever I give Reload there is some way for me to get the url from the console por exemplo a url dessa requisição que esta no console

  • Elvis, welcome to [en.so]! In my view it’s not very clear what you’re looking for. The console logs requests so you can inspect, but it’s not something that is part of a page’s scope. You want to monitor the requests made by the iframe? Want to run something with this or just inspect it on the console? How are you doing this now? Please try to clarify these points so we can help you better.

  • type this for example, I have an iframe on my page, this iframe makes a get, I need to get the url of this get more in this url has a variable that changes every time the page is visited and this variable works as a key understands, the variable is changed through the javascript of the iframe and as I can n change the code of the iframe n have to take this variable changed, the only way to achieve would be to get the console with all variables already certain

  • Unless you’re implementing an extension for Chrome, I don’t think you can access console information from your home page. Also, if your page is in a different domain than the iframe, then for security reasons it will be impossible for you to interact with it in Javascript.

  • What type of variable do you refer to? Is it a URL parameter or a global page variable? If you have access to iframe, Assuming there are no security restrictions, you could list all variables and identify the name of that variable you are looking for. Or even if this request uses Jquery, you can add a hook to listen to AJAX requests. But you would have to know more details to say exactly what is possible and what is not.

  • but iframe n lets me make modifications I’ll find some way to do it differently.

1 answer

-1

you can get the URL parameters through the object, window, follow an example below.

inserir a descrição da imagem aqui

Also follows another function to get the parameters in object format.

 function getQueryParams() {
   var queryParameters = window.location.search.split('+').join(' ');

   var params = {},
       tokens,
       re = /[?&]?([^=]+)=([^&]*)/g;

   while (tokens = re.exec(queryParameters)) {
     params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
   }

   return params;
 }
  • type are not the variables of my url the get is done through an external page wanted to pick up the variables of this external url remembering that this get is done by an iframe so I can’t get straight by my javascript

Browser other questions tagged

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