开发者

Javascript issue inside of a Python Module

开发者 https://www.devze.com 2023-03-18 22:54 出处:网络
I\'m trying to have Python run some Javascript, and I am running into a few issues. Namely that when I am trying to inject some text into a textarea of a page, it doesn\'t seem to work if and only if

I'm trying to have Python run some Javascript, and I am running into a few issues. Namely that when I am trying to inject some text into a textarea of a page, it doesn't seem to work if and only if there is a newline (\n) as part of the variable inserted for the Javascript.

Here's my line:

br.runjs("document.getElementById('edit-body').value = 开发者_如何学编程'%s'" % (brag))

if the variable "brag" has any sort of newline in it at all, the insertion does not work. Any idea how to go around this?


Encode brag as JSON and then use that.

0

精彩评论

暂无评论...
验证码 换一张
取 消