【问题标题】:'ScrollTop' is null or not an object'ScrollTop' 为 null 或不是对象
【发布时间】:2014-07-07 22:40:16
【问题描述】:

我正在向 DNN 网站上的表单添加验证码。我想使用 asp.net Recaptcha 控件,但它似乎不允许我轻松调整它的大小。

我决定将 HTML 插入到我的页面中,如下例所示:

https://developers.google.com/recaptcha/docs/customization

我在 Chrome 和 Firefox 上完美运行..但不是 IE ..至少不是 IE8 我正在使用的版本,我收到一个 javascript 错误“ScrollTop”为空或不是对象。错误发生在 dnncore.js 中

对 ScrollTop 的唯一引用在以下 js 函数中

function __dnn_bodyscroll() { 
var a = document.forms[0]; 
if (__dnn_ClientAPIEnabled() && __dnn_m_bPageLoaded) { 

//prob seems to happen on next lineafter a.
    a.ScrollTop.value = document.documentElement.scrollTop ? document.documentElement.scrollTop : dnn.dom.getByTagName("body")[0].scrollTop 
} 

}

function __dnn_setScrollTop(c) { 
if (__dnn_ClientAPIEnabled()) { 
    if (c == null) { 
        c = document.forms[0].ScrollTop.value 
    } 
    var a = dnn.getVar("ScrollToControl");
    if (a != null && a.length > 0) {
        var b = dnn.dom.getById(a);
        if (b != null) {
            c = dnn.dom.positioning.elementTop(b);
            dnn.setVar("ScrollToControl", "") 
        } 
    } 
    window.scrollTo(0, c) 
} 

}

在 IE 中使用此 ScrollTop 是否有替代方法?

Recpatcha 的 HTML 是

            <script type="text/javascript">
            var RecaptchaOptions = {
                tabindex: 1,
                theme: 'custom',
                custom_theme_widget: 'recaptcha_widget'
            };

            function switchType(type) {
                var input = document.getElementById('recaptcha_response_field');
                if (type == 'audio') {
                    input.placeholder = "Type what you hear";
                    Recaptcha.switch_type('audio');
                } else {
                    input.placeholder = "Type the text";
                    Recaptcha.switch_type('image');
                }
            }
        </script>
        <div id="recaptcha_widget" style="display: none">
            <div id="recaptcha_image">
            </div>
            <div class="recaptcha_input left">
                <div class="recaptcha_only_if_incorrect_sol" style="color: red;">
                    Incorrect, please try again</div>
                <input type="text" id="recaptcha_response_field" name="recaptcha_response_field"
                    placeholder="Type the text" />
            </div>
            <div class="recaptcha_buttons left">
                <a href="javascript:Recaptcha.reload()" title="Get a new challenge" id="recaptcha_reload_btn">
                    <img src="http://www.google.com/recaptcha/api/img/clean/refresh.png" id="recaptcha_reload"
                        alt="Get a new challenge" height="18" width="25"></a> <a href="javascript:switchType('audio');"
                            title="Get an audio challenge" id="recaptcha_switch_audio_btn" class="recaptcha_only_if_image">
                            <img src="http://www.google.com/recaptcha/api/img/clean/audio.png" id="recaptcha_switch_audio"
                                alt="Get an audio challenge" height="15" width="25"></a> <a href="javascript:switchType('visual')"
                                    title="Get a visual challenge" id="recaptcha_switch_img_btn" class="recaptcha_only_if_audio">
                                    <img src="http://www.google.com/recaptcha/api/img/clean/text.png" id="recaptcha_switch_img"
                                        alt="Get a visual challenge" height="15" width="25"></a>
                <a href="javascript:Recaptcha.showhelp()" title="Help" id="recaptcha_whatsthis_btn">
                    <img alt="Help" src="http://www.google.com/recaptcha/api/img/clean/help.png" id="recaptcha_whatsthis"
                        height="16" width="25"></a>
            </div>
            <img src="http://www.google.com/recaptcha/api/img/clean/logo.png" id="recaptcha_logo"
                alt="" height="36" width="71">
            <div class="clear">
            </div>
        </div>
        <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=mycaptchakey">
        </script>
        <noscript>
            <iframe src="http://www.google.com/recaptcha/api/noscript?k=mycaptchakey"
                height="300" width="500" frameborder="0"></iframe>
            <br>
            <textarea name="recaptcha_challenge_field" rows="3" cols="40" id="recaptcha_challenge_field" />
            <input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
        </noscript>

页面源中没有两个标签。我已经看到了造成这种情况的一些原因。

有人遇到过这个问题吗?

谢谢,

【问题讨论】:

    标签: javascript asp.net dotnetnuke captcha recaptcha


    【解决方案1】:

    好的,我想我找到了与 textarea 标签有关的原因。

    我用“/textarea”替换了“textarea”标签的结尾

    而且它似乎奏效了。 #crazybug

    【讨论】:

      猜你喜欢
      • 2018-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多