→ ssccg:以你這個例子,不要把參數放在html裡就好了吧 01/31 19:59
因為要從資料庫撈資料 那請問要如何塞給javascript呢? 有試過如果
在js裡用 var myString='<h1 name="test">test</h1>';
就可以成功
※ 編輯: sing10407 來自: 1.168.223.136 (01/31 20:03)
推 LaPass:htmlencode 01/31 20:05
推 LaPass:我好像記錯了,綱綱試不出來... 01/31 20:11
→ LaPass:如果另外一個方法是把所有 \ 取代為 \\ 把再把 " 取代為 \" 01/31 20:11
→ LaPass: ^是在server端做處理的話,可以用 01/31 20:12
剛在onload中試過 將"用\"來取代 還是無法
如果沒有雙引號只有 onload="myfun('<p>測試</p>')" 可以成功
onload="myfun('<p name=\"test\">測試</p>')" 則失敗
※ 編輯: sing10407 來自: 1.168.223.136 (01/31 20:31)
→ seanstars:('<p name="test">測試</p>') 這樣呢? 01/31 21:22
正解 然後再replaceAll就行了
感謝幫我的每位大大
※ 編輯: sing10407 來自: 1.168.223.136 (01/31 22:03)
推 pm2001:urlencode跟urldecode server端跟javascript都有函式可以用 01/31 23:31