开发者

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

开发者 https://www.devze.com 2023-04-08 13:35 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
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

精彩评论

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

关注公众号