<script> var test = 'aaa'; var val = 'test==aaaa'; var value = val.substring(val.lastIndexOf('=')+1); var name = val.substring(0,val.indexOf('=')); if( window[name] == value ) alert('test = aaaa'); else alert('no'); </script>