admin管理员组文章数量:1332389
I've been searching for a while but all I could find was examples on how to actually make those requests...
What I'm trying to do is to check if a website is making an http request after I click a button to X site
Ex. .txt
I'm guessing there a way to get all the outgoing requests and then filter the list but I can't even get the requests
What I've done so far is just inserting the eventlistener to check that X button has been clicked and then is when I'd like to check for those requests.
<script language="javascript">
document.getElementById("button").addEventListener('click', buttonClicked, true);
function buttonClicked(){
-->Check requests made after button is clicked.<--
}
</script>
I've been searching for a while but all I could find was examples on how to actually make those requests...
What I'm trying to do is to check if a website is making an http request after I click a button to X site
Ex. http://test.s3.amazonaws./test/1.txt
I'm guessing there a way to get all the outgoing requests and then filter the list but I can't even get the requests
What I've done so far is just inserting the eventlistener to check that X button has been clicked and then is when I'd like to check for those requests.
<script language="javascript">
document.getElementById("button").addEventListener('click', buttonClicked, true);
function buttonClicked(){
-->Check requests made after button is clicked.<--
}
</script>
Share
edited Nov 13, 2015 at 17:03
the
21.9k12 gold badges74 silver badges102 bronze badges
asked Jan 7, 2012 at 2:03
Alvaro ArreguiAlvaro Arregui
6091 gold badge6 silver badges9 bronze badges
6
- 1 Have you heard about FireBug? It's an great tool for checking HTML/JS/Network stuff. You can simply trace if a page sends HTTP requests to anywhere! getfirebug./network – powtac Commented Jan 7, 2012 at 2:06
-
Don't understand wath you mean with
Check requests made after button is clicked.
. Do you like to get the file? – Gabriel Santos Commented Jan 7, 2012 at 2:07 - Nowadays you don't even need Firebug. All modern browsers have these tools built in (including Firefox, just recently; the lead developer of Firebug has a new job so the Mozilla folks needed to step it up). – T.J. Crowder Commented Jan 7, 2012 at 2:08
-
what do you intend to do actually? are you just capturing
<a>
clicks? or checking if they are trying to point you to as site? – Joseph Commented Jan 7, 2012 at 2:08 - @powtac i knoow you can do that, i've checked all the requests made and there are tons of them and I'm only interested in one. I just want to get the plete request url to later insert it in a webpage – Alvaro Arregui Commented Jan 7, 2012 at 4:25
1 Answer
Reset to default 9I made a basic script for this a while ago, basically you just wrap the built-in XMLHttpRequest
.
(function() {
'use strict';
var oldXHR, stateChangeHandler, prop;
oldXHR = window.XMLHttpRequest;
stateChangeHandler = function (evt) {
switch (this.readyState) {
case oldXHR.OPENED:
console.log('Request was made', this, evt);
break;
case oldXHR.DONE:
console.log('Request finished', this, evt);
break;
}
};
function newXHR() {
var xhr = new oldXHR();
xhr.addEventListener('readystatechange', stateChangeHandler);
return xhr;
}
// Copy original states and toString
for (prop in oldXHR)
newXHR[prop] = oldXHR[prop];
window.XMLHttpRequest = newXHR;
})();
本文标签: Check if a website is making X http request with javascriptStack Overflow
版权声明:本文标题:Check if a website is making X http request with javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742290905a2447776.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论