小编Mo7*_*med的帖子

从codebehind中的javascript函数中检索值

如何从代码隐藏中的javascript函数中检索值,在页面加载时... javascript函数如:

<script type="text/javascript">
        function isIFrame() {
            var isInIFrame = (top.location != self.location);
            if (isInIFrame) {
                return "inside";
            }
            else {
                return "outside";
            }
        }
    </script>
Run Code Online (Sandbox Code Playgroud)

和代码背后像:

protected void Page_Load(object sender, EventArgs e)
    {
        string resutOfExecuteJavaScript = "";
        // resutOfExecuteJavaScript = isIFrame(); // from javascript

        if (resutOfExecuteJavaScript == "inside")
        {
            // do something
        }
        else
        {
            // do something
        }
    }
Run Code Online (Sandbox Code Playgroud)

谢谢.

javascript c# asp.net code-behind

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net ×1

c# ×1

code-behind ×1

javascript ×1