如何替换 livecode 中的 html 文本
How to replace html text in livecode
我正在使用此代码用相同的单词替换一个带有删除的单词。它工作正常。
replace Str[1] with "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" in myHtml
但是当我更换它时,反之亦然,它不起作用。我正在使用此代码替换
replace "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" with Str[1] in myHtml
你的代码对我来说确实有效。它在第一个 answer
上击中并给 "def" 上色,但在第二个上恢复正常。也许您在转义 quotes
?
时遇到了一些问题
put "abc def" into myHtml
put "def" into Str[1]
replace Str[1] with "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" in myHtml
answer myHtml -- "def" is yellow and stroke
replace "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" with Str[1] in myHtml
answer myHtml -- "def" is back to normal text
具有两个按钮和一个文本字段的工作示例:
按钮 1:
on mouseUp
put the htmlText of field "MytextField" into myHtml
put item 1 of myhtml into str[1]
replace Str[1] with "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" in myHtml
set the htmlText of fld "MytextField" to myHtml
end mouseUp
按钮 2:
on mouseUp
put the htmlText of field "MytextField" into myHtml
put "abc" into str[1]
replace "<strike><font bgcolor=" & quote & "#FFFF00" & quote & ">" & Str[1] & "</font></strike>" with Str[1] in myHtml
set the htmlText of fld "MytextField" to myHtml
end mouseUp
以及我如何设置文本字段
set the htmltext of field "mytextfield" to "abc,def"
我正在使用此代码用相同的单词替换一个带有删除的单词。它工作正常。
replace Str[1] with "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" in myHtml
但是当我更换它时,反之亦然,它不起作用。我正在使用此代码替换
replace "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" with Str[1] in myHtml
你的代码对我来说确实有效。它在第一个 answer
上击中并给 "def" 上色,但在第二个上恢复正常。也许您在转义 quotes
?
put "abc def" into myHtml
put "def" into Str[1]
replace Str[1] with "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" in myHtml
answer myHtml -- "def" is yellow and stroke
replace "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" with Str[1] in myHtml
answer myHtml -- "def" is back to normal text
具有两个按钮和一个文本字段的工作示例:
按钮 1:
on mouseUp
put the htmlText of field "MytextField" into myHtml
put item 1 of myhtml into str[1]
replace Str[1] with "<strike><font bgcolor=" & quote & "yellow" & quote & ">" & Str[1] & "</font></strike>" in myHtml
set the htmlText of fld "MytextField" to myHtml
end mouseUp
按钮 2:
on mouseUp
put the htmlText of field "MytextField" into myHtml
put "abc" into str[1]
replace "<strike><font bgcolor=" & quote & "#FFFF00" & quote & ">" & Str[1] & "</font></strike>" with Str[1] in myHtml
set the htmlText of fld "MytextField" to myHtml
end mouseUp
以及我如何设置文本字段
set the htmltext of field "mytextfield" to "abc,def"