Can JavaScript set the mime type on window.open

后端 未结 2 1941
小鲜肉
小鲜肉 2021-01-18 14:53

I am trying to open a debug window within Javascript. Javascript will pass the debug window a JSON string which JSONView (a Chrome extension) should display in a nicely form

相关标签:
2条回答
  • 2021-01-18 15:03

    It is not possible.

    You'd be better off doing:

    console.log(JSON.parse($(".trend_chart").attr("data-trendChart")));
    
    0 讨论(0)
  • 2021-01-18 15:13

    The document that your opening should be of type "application/json" you cannot send it as a parameter in the window.open method since it's out of context. The browser instead is the one that determines the file type using the request headers.

    window.open("http://www.yoursite.com/file.json", "mywindow");
    

    You should see the json file within JSONView without problems. If the browser still asks you to download the file, your installation of JSONView is probably broken.

    0 讨论(0)
提交回复
热议问题