开发者

How to inject a JavaScript function and its call from text area? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

How can I submit a function definition and its call from

<input type="text">

tag?

EDIT: My friend have written a php script where he takes the value of tag and without calling strip_tags function prints on another page. Now 开发者_StackOverflow中文版I want to show an example with JavaScript (I believe it should be possible) that I can inject a JavaScript code into his website. That is my task.


If you want to invoke script from your textbox, try to use eval in javascript.

<script type="text/javascript">
    function Invoke()
    {
        var ctrl = document.getElementById('content')
        eval(ctrl.value);
    }
</script>

<input type="text" id="content" />
<input type="button" onclick="Invoke()" value="Invoke" />

Code: http://jsfiddle.net/AuPRM/


Assign the return value of yourFunction.toString() to the value property of the field.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜