我只想將基礎url傳遞給一個javaScript函數。函數調用就像如下如何將url作爲參數傳遞給JavaScript函數?
<img src="assets/images/c_arow_rite.jpg" onClick="nextMonth('.$bs_url.')"/>
它顯示像
Error: SyntaxError: identifier starts immediately after numeric literal
Source File: `http://mywebsite/rand/`
Line: 1, Column: 15
Source Code:
nextMonth(http%3A%2F%2F192.168.1.254%2Frand%2F)
把它作爲一個字符串? – TheZ
嘗試將雙引號內的URL作爲字符串傳遞。 –
不要通過它? 'location.href','location.host','location.pathname','location.protocol','location.port' ...已經有很多信息可供您使用。如果它不是當前網址,那麼只有在php引號是「或heredoc afaik,而不是' –