خرید بک لینک
Hello,

I'm trying to show a json string in a new tab. Here's my code:

Code:

            var parsedJson = JSON.parse(ra.reportConfigPage.ReportJson);
            var prettifiedJson = JSON.stringify(parsedJson, null, 4);
            window.open("data:text/html;charset=utf-8,<pre>" + prettifiedJson + "</pre>");

This code doesn't work. I just get my json string in one big line (have to scroll to see it all).

I'm using this fiddle as a guide, which does work:

Edit fiddle - JSFiddle

The only difference is that I'm trying to pass a prettified json string to a new browser tab whereas the fiddle example is just adding it to the ier html of a <pre> element.

What can I do to get the prettified version to show up in a new browser tab?

برچسب: نویسنده: آیلین رضوانی تاريخ: سه شنبه 20 تير 1396 ساعت: 4:56

صفحه بندی