Languages

Menu
Sites
Language
How to pass parameters, a html page to another html page

If I click on a button to jump to another page,  need to transfer data,  and how to accept another page

thanks

Responses

6 Replies
AVSukhov

Hello,

You can use many ways:

- localStorage or sessionStorage

- global js object

- database

- save to file

- widget preferences

 

Seoghyun Kang

Hello,

 

You can make it without moving the pages.

Because there is no moving pages, there is no need to transfer the data.

 

Please refer the following code. When user click the button, page will be changed without the moving.

 

1. HTML

<body>
    <div data-role="page" id="First">
        First Page
        <button onclick="move()">Move</button>
    </div>
    <div data-role="page" id="Second">
         Second Page
    </div>
</body>

 

 

2. CSS

#First {
    display: block;
}

#Second {
    display: none;
}

 

3. JS

function move() {
    document.getElementById('Second').style.display = 'block';
    document.getElementById('First').style.display = 'none';
}

 

Thanks

 

ps. If domain address is changed when you move the page, you need to use the "GET" or "POST" method.

 But I assume that your situation is not that.

 

 

Palitsyna

Hello,

as AVSukhov said, there are many ways to transfer data. You can find developers guide about Storage and choose the most suitable for your purpose approach here:

https://developer.tizen.org/development/guides/web-application/w3chtml5supplementary-features/storage-0

 

YONG LEI

   

 very thanks.

  I have a question,   about The use and the description of tau.js

Palitsyna

use 

tau.changePage ("#pageID", 'slide');

to go to the page with "pageID" id. 

 

Here you can find full documentation about page changes:

https://developer.tizen.org/development/api-references/web-application?langswitch=en

pius lee

If your data size under than 2k, you can send data to other page with GET (http method).

Just use window.location.search and GET

 

index.html

<!DOCTYPE html>
<html>
<body>
<form action="page2.html" method="get">
    <input type="hidden" name="data" value="foobar">
	<input type="submit" value="SEND FOOBAR TO NEXT PAGE">
</form>
</body>
</html>

yes sure, if you don't want use form, you can just make url yourself in javascript like this.

page2.html?data=foobar

 

page2.html

<!DOCTYPE html>
<html>
<body>
<script>
function getQueryStringValue (key) {  
    return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));  
}

</script>
<div>data : <span id="data"></span></div>

<script>
document.getElementById("data").innerHTML = getQueryStringValue("data");
</script>
</body>
</html>