javascript - How can I get access to value of a field in a HTML page inside other pages -
my problem want take value of text field 1 html page one.
according following code, @ first page, can value of sms_name
text field using onclick
attribute. can not access @ other page.
i used many solutions no success until now.
html file #1:
<div style="width:100%;height:34%;;margin-top:20%" > <div class="message-onclick" onclick=" var sms_name= document.getelementbyid('recepient-name').value; alert(sms_name); "> </div> </div>
html file #2:
<div class="log-divs" style="height:7%;border:1px solid red" onclick=" alert(sms_name); "> </div>
if want using javascript only, don't need particular js library, pass value second page using parameter:
in first file:
window.location.href = 'secondfile.html?sms_name=' + sms_name;
in second file:
var param = 'sms_name'; // position of parameter in url var paramindex = window.location.href.indexof(param + '=') , value = window.location.href.substr(paramindex + param.length); // find value ends var valueendindex = value.indexof('&'); // if other params follow, take them off if (valueendindex !== -1) value = value.substr(0, valueendindex); // should alert(value);
Comments
Post a Comment