Mike4997955
Posts: 0
Joined: Wed Sep 12, 2012 7:50 pm

opening a browser with a local variable

I'm using a button to open a web browser, and I get the URL from a local variable. Here's the javascript i'm using:
window.open("'+localStorage.getItem('GooglePicsURL')+'")

It opens a browser window, but not the correct URL. It open to: http://project.tiggzi.com/404.html
Is my javascript incorrect?

Thank you.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

opening a browser with a local variable

What is the correct URL? It opens what you have in window.open(..).

Mike4997955
Posts: 0
Joined: Wed Sep 12, 2012 7:50 pm

opening a browser with a local variable

The correct URL is https://www.google.com/search?&tbm=is...

But it can change because it is a variable. the local variable is GooglePicsURL, and the string isn't working in the open command. I thought that "'+localStorage.getItem('GooglePicsURL')+'" would get the string.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

opening a browser with a local variable

You don't need the ", just use this:

code
window.open(localStorage.getItem('GooglePicsURL'));
/code

Mike4997955
Posts: 0
Joined: Wed Sep 12, 2012 7:50 pm

opening a browser with a local variable

Thanks again!

Return to “Issues”