最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do i create a url that returns a 204 - Stack Overflow

programmeradmin6浏览0评论

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 = '';?
    }  ?
}, 1);?
</script>

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

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.';?
    }  ?
}, 1);?
</script>

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

Share edited Jul 17, 2016 at 1:23 Yehia Awad 2,9881 gold badge22 silver badges31 bronze badges asked Jul 17, 2016 at 1:10 llrenoldsllrenolds 311 silver badge5 bronze badges 3
  • 3 this thing is made by the server (Backend), just imagine the security gap if a simple user could do that – Yehia Awad Commented Jul 17, 2016 at 1:24
  • @YehiaAwad - Who are you calling "simple"? In any case, the answer would be "do it server-side with steps A, B, and C". – nnnnnn Commented Jul 17, 2016 at 1:29
  • @nnnnnn simple user I mean a site visitor. don't understand me wrong ) – Yehia Awad Commented Jul 17, 2016 at 1:31
Add a ment  | 

2 Answers 2

Reset to default 5

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

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
发布评论

评论列表(0)

  1. 暂无评论