开发者

value was "" blank when refreshing the page manually

开发者 https://www.devze.com 2022-12-31 00:48 出处:网络
I have a problem regarding the maintaining of value when page was refresh.I assign a value into a hidden control using javascript below:

I have a problem regarding the maintaining of value when page was refresh.I assign a value into a hidden control using javascript below:

function displaytab(tabID) {
开发者_运维百科   var tabId = document.getElementById("ctl00_MainContent_tabId"); 
    switch (tabID) {
        case 1:
          tabId.value=1;
          break;
        case 2:
          tabId.value=2;

          break;
        case 3:
          tabId.value=3;

          break;
        default:
         tabId.value=0;

           break;     
     }

but when i refresh the page the value was ("") blank. Is there any way how to resolved this issue? or what is the best way to do this?


You might consider putting the values you need to store across refreshes into the page anchor (the part of the URL following the # sign). You can access this in javascript via the location.hash member.


Ensure displayTab is not called until the DOM is ready.

A easy way would be calling your function in window.onload:

window.onload = function()
{
    displayTab(123);
};
0

精彩评论

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

关注公众号