javascript将字符串转为对象

javascript将字符串转为对象
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script>
            var keyword = window.location.search.substring(1);
            // 取查询字符串
            var pos = keyword.indexOf('=');
            var argname = keyword.substring(0, pos);
            var JobType;
            keyword = decodeURIComponent(keyword.substring(pos + 1));
            
            eval(argname + " = \"" + keyword + "\";");
            console.log(JobType);
        </script>
    </head>
    <body></body>
</html>

 

posted @ 2014-08-14 13:44  地信小哥  阅读(584)  评论(0编辑  收藏  举报