Reputation: 5
Basically im trying to make a dynamic variable saved in local storage to be used as a redirect URL.
<meta http-equiv="refresh" content="0; url=<script type="text/javascript">
document.write('webpage')</script>" />
<script type="text/javascript">
function urlsave(){
localStorage.setItem('webpage','http://example.com/');
}
/<script>
So in theory it would send you to whatever URL is stored in the 'webpage' variable, this case being http://example.com/.
This is the idea anyway. Im still fairly new to programing, but am curius if this would work. And if not, how would i MAKE it work? Thanks.
Upvotes: 0
Views: 1693
Reputation: 3765
Set first the webpage, then call getItem.
<script type="text/javascript">
localStorage.setItem('webpage','http://www.google.com');
var dest = localStorage.getItem('webpage')
document.write("<meta http-equiv='refresh' content='0; url="+dest+"'/>");
</script>
Upvotes: 1