2010-07-30 63 views
1

我想通過單擊按鈕來傳遞URL,以便瀏覽器可以重定向到URL。單擊按鈕時如何重定向瀏覽器?

url值= /web/SMI6041001090/home?contId=186&contName=sa

當用戶點擊按鈕應該重定向到該URL。

var url = document.<portlet:namespace />regForm.fwdURL.value; 
alert('url -->'+url); 

jQuery('.submit-button').click(function(){ 
    // Pass URL here. 
}); 
+0

不知道你是問什麼? – 2010-07-30 10:43:09

回答

2

我想通過URL的 按鈕CLIK。所以瀏覽器可以重定向到 的URL。

你的意思是這樣的:

var url = document.<portlet:namespace />regForm.fwdURL.value; 

jQuery('.submit-button').click(function(){ 
    document.location.href = 'http://yoursite.com' + url; 
}); 
+0

sAc,document.location和window.location有什麼區別? – fearofawhackplanet 2010-07-30 10:43:47

+0

@fearofawhackplanet:你可以使用'location'是window/document'對象的屬性。 – Sarfraz 2010-07-30 10:45:10

+0

@fear:* document.location *最初只在某些瀏覽器中是隻讀的。正因爲如此,* window.location *總是將瀏覽器定向到另一個位置的首選方法,但這些日子並不重要。 – 2010-07-30 10:48:59

相關問題