开发者

Data transaction between webpages

If you have two pages named index1 and index2

When you click a link and you want to transfer some data from index1 to index2. The Data is located in the website only. You are only allowed to use HTML, javascript and CSS only.

One more thing, you also have a big list and if you click one of them, then you will be transfered to a new page (index2) with more information about the topic/data you have chosen.

开发者_高级运维How should I do it?


You could pass this data as query string parameters

<a href="index2.htm?param1=value1&amp;param2=value2">Go to index2</a>

and in index2.htm you could use javascript to read this parameters from the window.location.href. Here's one useful method.

Another possibility if those two sites are on the same domain consists into using cookies. Thus the index1.htm page could use javascript to set a cookie and then simply redirect to index2.htm which will read the values from this cookie (once again this works only if the two pages are hosted on the same domain).


You may use store some data in browser using javascript in key value format, see this plugin http://www.domcached.com/

Now on index2.html , get that data back from dom-cache using the plugin, and render to user

Limitations

a> wont' work if javascript is disabled

b> Size of data to be stored

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜