0

This is all I've got going, but my debugger says 'document.write can be a form of eval,' and my jsonString variable prints as undefined. Any help is appreciated, thanks.

function getUrlVars() {
        var map = {};
        var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
                                                 map[key] = value;
                                                 });
        return map;
    }

    var jsonString = getUrlVars()['json'];
    document.write(jsonString);
Wipqozn
  • 1,282
  • 2
  • 17
  • 30

1 Answers1

3

The reason document.write can be a form of eval is because if you write a script element it will be evaluated.

As for why your jsonString is undefined, you probably don't have a parameter named 'json'.

Samuel Edwin Ward
  • 6,526
  • 3
  • 34
  • 62