Thursday, April 19, 2018

javascript 網址間相互傳值


A網址URL : localhost/test/newOpen.aspx?A=TestingA&B=TestingB&C=TestingC



需求: 取得A網址中Request("C")的值, 並以javascript帶入B網址中
預期 B網址URL : localhost/test/editOpen.aspx?editA=editA&C=TestingC


解法:
  前端藏欄位 -> 後端取值 -> 丟回前端, 串回URL
  
Client端: 
 <input id="getC" type="hidden" runat="server" />   

Server端:
getC.Value=Request("C")

Javascript部份:
window.open("URL?&C=" + document.getElementById('getC').value + ""); 

No comments:

Post a Comment