Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i create a url that returns a 204

I am trying to use the i frame buster buster code but i need to use a 204 url. How do i create page that gives of a 204 no content error so that this iframe bustter buster code works

<script type="text/javascript">?

var prevent_bust = 0;?
window.onbeforeunload = function() { prevent_bust++; }?
setInterval(function() {?
    if (prevent_bust > 0) {  ?
        prevent_bust -= 2;?
        window.top.location = 'http://domain.com';?
    }  ?
}, 1);?
</script>

in the window.top.location = i am suppose to a 204 url so how do i create one

like image 405
llrenolds Avatar asked Nov 02 '26 01:11

llrenolds


2 Answers

Use this service http://httpstat.us/. Just add the status code you want at the end. i.e. http://httpstat.us/204

like image 171
Ross Lote Avatar answered Feb 25 '26 03:02

Ross Lote


Http Response Status codes are returned by the server of the page you are sending a HTTP request to. This information is transferred via HTTP (Hyper Text Transfer Protocol) and is NOT something you can control from the client side javascript.

So for you, you would need to create a page on your site that returns this status code in it's http headers and redirect to it from your javascript.

Since you don't specify what server technology you are using, here are some links on how to set the response codes in a few different languages:

  • PHP
  • .NET
  • Node Express
like image 24
gkeenley Avatar answered Feb 25 '26 02:02

gkeenley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!