0

I know this might sound silly and the easier alternative is to convert my pages to PHP. But is there a way to do this in HTML with Javascript or jQuery?

i want to sending JSON string from one HTML page to another.

in first.html there is a set of images that gets converted into a JSON string that looks like this:

{"images":[ {"src":"images/en1.png"},
    {"src":"images/en4.png"},
    {"src":"images/en2.png"},
    {"src":"images/fr4.png"},
    {"src":"images/b40.png"},
    {"src":"images/ca7.png"}
]}

i want to send this to second.html and in there a button called edit will take all this back to first.html

Is there a way to do this or is it impossible?

1
  • given that you're dealing with client-only functionality, you might do better to just use jQuery to show/hide sections on a single HTML page, this will probably be less complicated and more reliable than trying to serialized/deserialize a cookie.. Commented Jul 7, 2012 at 13:11

3 Answers 3

2

You could use querystring for that

something like

    <a 
href='second.htm?images={"images":[ {"src":"images/en1.png"},{"src":"images/en4.png"},{"src":"images/en2.png"},{"src":"images/fr4.png"},"src":"images/b40.png"},{"src":"images/ca7.png"}]}' >
    Go to second page
    </a>

and on second.htm you can get that value by using

window.location.href
Sign up to request clarification or add additional context in comments.

Comments

1

You can use :

cookies to store the string and read the cookie in second html

passing the entire string(JSON stringify) as a URL parameter

Comments

1

You could take advantage of HTML5 offline storage using Andris Reinman's jStorage library. Just call the set method from your first.html page and the get method from your second.html page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.