繁体   English   中英

在Android Internet浏览器中隐藏HTML的元素

[英]Hiding elements of HTML in android internet browser

我正在针对Android互联网浏览器的测试项目。 我正在使用JavaScript隐藏一些对象onLoad。

问题是,它可以在mozilla firefox中工作,但不能在android默认Internet浏览器中工作。

这是我的完整代码:

<!DOCTYPE html>
<html>

<script type="text/javascript" async>

function ajaxpath_59c479660b217(url){return window.location.href == '' ? url : url.replace('&s=','&s=' + escape(window.location.href));}(function(){document.write('<div id="fcs_div_59c479660b217"></div>');fcs_59c479660b217=document.createElement('script');fcs_59c479660b217.type="text/javascript";fcs_59c479660b217.src=ajaxpath_59c479660b217((document.location.protocol=="https:"?"https:":"http:")+"//www.freecommentscript.com/GetComments2.php?p=59c479660b217&s=#!59c479660b217");setTimeout("document.getElementById('fcs_div_59c479660b217').appendChild(fcs_59c479660b217)",1);})();

    function myFunction() {
    document.getElementById("comment-ad").style.display = "none";
}

function myFunction2() // no ';' here
{
    var elem = document.getElementById("fcs_Comment_59c479660b217");
    if (elem.value=="Enter your comment here") elem.value = "Enter your post here";
    else elem.value = "Enter your post here";
}

function myFunction3() // no ';' here
{
        document.getElementById("comment-rss-feed").style.display = "none";

}

function showFilterItem() {
    if (filterstatus == 0) {
        filterstatus = 1;
        $find('<%=FileAdminRadGrid.ClientID %>').get_masterTableView().showFilterItem();
        document.getElementByClassName("ShowButton").innerHTML = "Hide Filter";
    }
    else {
        filterstatus = 0;
        $find('<%=FileAdminRadGrid.ClientID %>').get_masterTableView().hideFilterItem();
        document.getElementById("ShowButton").innerHTML = "Show filter";
    }
}


if (document.readyState === "complete") {
   myFunction();
   myFunction2();
   myFunction3();
   showFilterItem();
}
else {
   window.onload = function () {
      myFunction();
      myFunction2();
      myFunction3();
      showFilterItem();
   };
};

</script>


</body>
</html>

我将整个脚本放入domloaded事件中,以确保js可以找到dom元素。 像那样:

<script type="text/javascript" async>
document.addEventListener('DOMContentLoaded', function(){
function ajaxpath_59c479660b217(url){return window.location.href == '' ? url : url.replace('&s=','&s=' + escape(window.location.href));}(function(){document.write('<div id="fcs_div_59c479660b217"></div>');fcs_59c479660b217=document.createElement('script');fcs_59c479660b217.type="text/javascript";fcs_59c479660b217.src=ajaxpath_59c479660b217((document.location.protocol=="https:"?"https:":"http:")+"//www.freecommentscript.com/GetComments2.php?p=59c479660b217&s=#!59c479660b217");setTimeout("document.getElementById('fcs_div_59c479660b217').appendChild(fcs_59c479660b217)",1);})();

    function myFunction() {
    document.getElementById("comment-ad").style.display = "none";
}

function myFunction2() // no ';' here
{
    var elem = document.getElementById("fcs_Comment_59c479660b217");
    if (elem.value=="Enter your comment here") elem.value = "Enter your post here";
    else elem.value = "Enter your post here";
}

function myFunction3() // no ';' here
{
        document.getElementById("comment-rss-feed").style.display = "none";

}

function showFilterItem() {
    if (filterstatus == 0) {
        filterstatus = 1;
        $find('<%=FileAdminRadGrid.ClientID %>').get_masterTableView().showFilterItem();
        document.getElementByClassName("ShowButton").innerHTML = "Hide Filter";
    }
    else {
        filterstatus = 0;
        $find('<%=FileAdminRadGrid.ClientID %>').get_masterTableView().hideFilterItem();
        document.getElementById("ShowButton").innerHTML = "Show filter";
    }
}


if (document.readyState === "complete") {
   myFunction();
   myFunction2();
   myFunction3();
   showFilterItem();
}
else {
   window.onload = function () {
      myFunction();
      myFunction2();
      myFunction3();
      showFilterItem();
   };
};
});
</script>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM