2009-12-14 59 views
1

我發展在asp.net C#中,其中有這樣一個URL的Web應用程序在每次刷新後的值...增加在JavaScript

http://localhost:1096/DisplayPop3Email.aspx?emailId=10 

給定的時間之後,我想刷新頁面,增加值emailId。這是一段重複的過程,應該在一段時間過後纔會發生。

第一次刷新後,URL現在應該是這樣的......

http://localhost:1096/DisplayPop3Email.aspx?emailId=11 

我寫了一個javascript函數在一定時間後刷新頁面,但我怎麼能增加EMAILID的價值每次刷新後?

這是我的Javascript代碼...

<script type="text/javascript"> 
    var sURL = unescape(window.location.pathname); 

    function doLoad(){ 
     setTimeout("refresh()", 2*15000); 
    } 

    function refresh(){ 
     window.location.href = sURL; 
    } 
</script> 

<script type="text/javascript"> 
    function refresh() { 
     window.location.replace(sURL); 
    } 
</script> 

我打電話doload()從裏面另一個JavaScript函數,如下面...

<script type="text/javascript"> 
    function openNewWindow(spcd,cval) { 
     var tt = spcd; 
     var testarray=(spcd).split('@%@'); 

     for(i=0;i<testarray.length-1;i++) { 
      var theurl=testarray[i]; 

      if(theurl=="http://www.colbridge.com"){ 
       popupWin = window.open(theurl,'_blank','menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0') 
       break; 
      } 
     } 

     receiveval(cval); 
     doLoad(); 
    } 
</script> 

我打電話openNewWindow(spcd)我的asp.net page_load內事件。

可能有人請幫我找出如何增加每次刷新後的計數器。

回答

1

撥打以下功能:

function goToNextId() { 
    var id = 1 + parseInt(window.location.href.match(/emailId=(\d+)/)[1]); 
    window.location.href = window.location.href.replace(/emailId=(\d+)/, "emailId=" + id); 
}