为什么javascript不支持移动浏览器 [英] Why javascript not support in mobile browser

查看:105
本文介绍了为什么javascript不支持移动浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我开发了移动网站。但JavaScript验证无法在移动浏览器中运行。您可以在移动浏览器中提供支持JavaScript的一些想法。谢谢提前。



 <%@       语言  =  VB    CodeFile   =  mAtimsMaster.master.vb    AutoEventWireup   =  True   

继承 = Mobile_Source_mAtimsMaster %>





<%@ Register TagPrefix = Uc1TagName =RequestPendingSrc =〜/ Mobile / mSource / mUserControls / mRequest / mRequestPending.ascx%> 
<%@ Register TagPrefix =Uc2TagName =RequestAssignedSrc =〜/ Mobile / mSource / mUserControls / mRequest / mRequestAssigned.ascx%>

<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional。 DTD>
< html xmlns =http://www.w3.org/1999/xhtml>
< head runat =server>
< title>< / title>
< meta http-equiv =X-UA-Compatiblecontent =IE = edge/>
< meta name =viewportcontent =width = device-widthinitial-scale =1.0;最大规模=1.0;
user-scalable =0; />
< meta name =HandheldFriendlycontent =true/>
< meta name =MobileOptimizedcontent =width/>
< link href =../ mStyles / mDefault.css =stylesheettype =text / css/>
< script type =text / javascript>
函数ShowHideMenu(){
var MenuDiv = document.getElementById('MenuDiv');
var menuWidth = $('#MenuDiv')。width();
var HeaderSubdiv = document.getElementById('HeaderSubdiv');
var ContentDiv = document.getElementById('DivContent');
var windowwidth = $(window).width();
HeaderSubdiv.style.width = windowwidth +'px';
ContentDiv.style.width = windowwidth +'px'
if($('#MenuDiv')。is(':visible')){
$('#MenuDiv')。隐藏();
HeaderSubdiv.style.width = '99 .8%';
ContentDiv.style.width = '99 .8%';
}
else {
$('#MenuDiv')。show();
var height = $(document).height();
$(#MenuDiv)。each(function(){
$(this).css('min-height',height +'px');
});
menuWidth = menuWidth - 15;
$('。MenuArrowDiv')。css('margin-left',menuWidth +'px');
}
}
< / script>
< asp:ContentPlaceHolder ID =HeadContentrunat =server>

< / head>
< body>
< form id =form1runat =server>
< asp:ScriptManager ID =ScriptManager1runat =server>
< Scripts>
< asp:ScriptReference Path =〜/ Source / SCRIPTS / jquery191.js/>
< asp:ScriptReference Path =〜/ Source / SCRIPTS / TextBoxValidate.js/>
<% - < asp:ScriptReference Path =〜/ Source / SCRIPTS / IE10Support.js/> - %>
< / Scripts>

< div id =IMGDIVstyle =display:none; font-family:Verdana,Arial,Helvetica,sans-serif;< br mode =hold =/> font -size:11px; font-style:normal; position:absolute; width:90%; height:0%;< br mode =>
< div style =width:200px; text-align:center; margin:0 auto;>
< div style =width:200px; height:60px; float:left; text-align:center; border-style:inset;< br mode =hold =/> border-color: #444468; background-color:#E5F1FF; border-width:3px; padding-bottom:5px;>
< div style =width:180px; height:45px; float:left; text-align:center; border-style:outset;< br mode =hold =/> border-color: #E5F1FF; border-width:10px;>
< font color =#444468style =font-family:Times New Roman Baltic; font-size:x-large;< br mode =hold =/> font-weight:bold ; font-style:italic;> Processing ...< / font>< br />
< asp:Image ID =ldimgrunat =serverImageUrl =〜/ Source / Images / LoadingImg.gif/>
< / div>
< / div>
< / div>
< / div>
< div id =MaskedDivclass =MaskedDivrunat =serverclientidmode =Static>

< div id =WholeDivrunat =serverclientidmode =Staticclass =Page>
< asp:HiddenField ID =HdnWindowWidthrunat =server/>
< div id =MenuDivrunat =serverclientidmode =Staticstyle =width:auto; float:left;
background-color:#1f2d3f; display:none;> ;
< div style =width:auto; float:left; height:auto;>
< div id =MenuTitleDivrunat =serverstyle =text-align:center; font-weight:bold;
font-size:medium; color:white; padding:16px; border-bottom:1px solid#300;>
ATIMS Mobile Web
< / div>
< ul>
< asp:Repeater ID =RptMenurunat =serverOnItemDataBound =RptMenu_ItemDataBound>
< itemtemplate>
< div id =MenuDivsubrunat =serverstyle =cursor:pointer; margin-top:5px; margin-left:-40px;
padding-left:5px; padding-right :15px;>
< li id =LiMenurunat =serverstyle =list-style-type:none; cursor:pointer; width:auto;
font-size:medium;>
< asp:LinkBut​​ton ID =LnkBtnMenurunat =serverOnClick =LnkBtnMenu_ClickStyle =text-decoration:none;>
< asp:HiddenField ID =HdnUrlrunat =serverValue ='<%#DataBinder.Eval(Container,DataItem.UserControl)%>'/>
< span>
< div id =DivMenuTitlerunat =serverstyle =color:white; font-weight:bold; cursor:pointer;
text-decoration:none; vertical-align:middle; padding-left:5px;>
< asp:Image ID =ImgMenurunat =serverImageAlign =AbsMiddle/>
< asp:Literal ID =LtlMenuTextrunat =serverText ='<%#DataBinder.Eval(Container,DataItem.MobileWeb_Title)%>'>

< / span>

< div id =MenuArrowDivrunat =serverclass =MenuArrowDiv>
< div class =Arrow-Left>
< / div>



< / itemtemplate>

< / ul>


< div id =contentdivrunat =serverclientidmode =Staticstyle =overflow:hidden;>
< div style =width:100%; float:left; height:auto;>
< div id =HeaderDivrunat =serverclientidmode =Staticstyle =height:auto; width:99.8%;>
< div id =HeaderSubdivrunat =serverclientidmode =Staticstyle =float:left; width:100%;
border:1px solid#300;>
< div id =DivSystemSelectstyle =float:left; width:auto; cursor:pointer; runat =server$ b $bönclick=ShowHideMenu();>
< asp:Image ID =ImgBtnSysSelectrunat =serverImageUrl =〜/ Mobile / mImages / mTop_SysSelect.bmp
ToolTip =System SelectStyle =width:auto; height :汽车; />
< / div>
< div id =RequestDivrunat =serverstyle =width:auto; height:auto; text-align:left;
float:left; padding-top:3px; padding- left:3px; padding-right:3px;>
< div style =width:auto; text-align:left; height:auto;>
< asp:LinkBut​​ton ID =LnkBtntPendingrunat =serverText =0 PendingCssClass =HeaderMessageLink>
< / div>
< div style =width:auto; text-align:left; height:auto;>
< asp:LinkBut​​ton ID =LnkBtnAssignedrunat =serverText =0 AssignedCssClass =HeaderMessageLink>
< / div>

< div id =ApplicationNameDivrunat =serverstyle =width:auto; height:auto; float:left;>
< div id =ApplnDivrunat =serverstyle =width:auto; height:auto; text-align:center;
line-height:50px; vertical-align:middle; padding-left:0.3em; position:relative;
margin:0 auto;>
< asp:Label ID =LblApplicationrunat =serverCssClass =HeaderLine1Text =>


< div id =LogoutDivrunat =serverstyle =width:auto; height:auto; float:right;
cursor:pointer;> ;
< asp:ImageButton ID =ImgBtnLogoutrunat =serverToolTip =LogoutImageAlign =AbsMiddle
ImageUrl =〜/ Mobile / mImages / mLogout.pngStyle =cursor :指针; />

< div id =HomeDivrunat =serverstyle =width:auto; height:auto; float:right;
cursor:pointer;>
< asp:ImageButton ID =ImgBtnHomerunat =serverToolTip =Go To Home PageImageAlign =AbsMiddle
ImageUrl =〜/ Mobile / mImages / mTop_Home.bmp/ >



< div id =DivPendingrunat =serverstyle =width:99%; float:left; height:auto;
position :absolute; display:none; background-color:White; border:2px solid#00264D;>
< Uc1:RequestPending ID =RequestPending1runat =server/>

< div id =DivAssignedrunat =serverstyle =width:99%; height:auto; float:left;
position:absolute; display:none; background -color:白色;边框:2px solid#00264D;>
< Uc2:RequestAssigned ID =RequestAssigned1runat =server/>

< div id =DivContentrunat =serverclientidmode =Staticstyle =float:left; height:auto;
width:99.8%;>
< asp:ContentPlaceHolder ID =MainContentrunat =server/>




< / form>
< / body>
< / html>


代码背后
进口系统
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Partial Class Mobile_Source_mAtimsMaster
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(ByVal sender As Object,ByVal e As System.EventArgs)Handles Me.Load
试试
AddHandler RequestAssigned1.AssignedBack,AddressOf HandleAssignedCloseEventIn
AddHandler RequestPending1.PendingBack,AddressOf HandlePendingCloseEventIn
If Not IsPostBack Then
Dim dt As New DataTable
Dim objMobileBL As New BLMobileMaster
dt = objMobileBL.GetApplicationModuleList()
RptMenu.DataSource = dt
RptMenu.DataBind()
如果会话(CurrentScreen)<> 然后
LblApplication.Text =会话(CurrentScreen)
否则
LblApplication.Text =LandingPage
结束如果
结束如果

如果Session(CurrentScreen)IsNot Nothing则
如果RptMenu.Items.Count> 0然后
For Each menutype As RepeaterItem In RptMenu.Items
Dim DivArrow As HtmlGenericControl = DirectCast(menutype.FindControl(MenuArrowDiv),HtmlGenericControl)
Dim ListMenu As HtmlGenericControl = DirectCast(menutype。 FindControl(LiMenu),HtmlGenericControl)
Dim getMenuName As Literal = DirectCast(menutype.FindControl(LtlMenuText),Literal)
ResetStyle(RptMenu)
If Session(CurrentScreen) = getMenuName.Text然后
DivArrow.Style.Add(display,block)
ListMenu.Attributes.Add(class,menu-title)
LblApplication.Text =会话(CurrentScreen)
退出
结束如果
下一个
结束如果
结束如果
CheckRequest()
Catch ex As Exception
Dim ObjBlCommon As New BLCommon:ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub

Protected Sub RptMenu_ItemDataBound (sender As Object,e As System.Web.UI.WebControls.RepeaterItemEventArgs)处理RptMenu.ItemDataBound
尝试
如果e.Item.ItemType = ListItemType.AlternatingItem OrElse e.Item.ItemType = ListItemType.Item然后
Dim imgMenu As Image = DirectCast(e.Item.FindControl(ImgMenu),Image)
Dim ltlText As Literal = DirectCast(e.Item.FindControl(LtlMenuText),Literal)
选择案例(ltlText.Text)
案例我的设置
imgMenu.ImageUrl =〜/ Mobile / mImages / mMySetting.png
案例我的控制台
imgMenu.ImageUrl =〜/ Mobile / mImages / mMyConsole.png
案例选择控制台
imgMenu.ImageUrl =〜/ Mobile / mImages / mSelectConsole.png
案例我的房屋
imgMenu.ImageUrl =〜/ Mobile / mImages / mMyHousing.png
案例选择住房
imgMenu.ImageUrl =〜/ Mobile / mImages / mSelectHousing.png
案例我的位置
imgMenu.ImageUrl =〜/ Mobile / mImages / mMyLocation.png
案例搜索地点
imgMenu.ImageUrl =〜/ Mobile / mImages / mSearchLocation.png
案例我最后的囚犯
imgMenu.ImageUrl =〜/ Mobile / mImages / mLastInmate.png
Case搜索犯人
imgMenu.ImageUrl =〜/ Mobile / mImages / mSearchInmate.png
案例请求菜单
imgMenu.ImageUrl =〜/ Mobile / mImages / mRequestMenu.png
结束选择
结束如果
Catch ex As Exception
Dim ObjBlCommon As New BLCommon:ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub

Protected Sub LnkBtnMenu_Click(sender As Object,e As System.EventArgs)
Try
Dim LnkBtnMenu As LinkBut​​ton = DirectCast(sender,LinkBut​​ton)
Dim MenuItem As RepeaterItem = DirectCast(LnkBtnMenu.NamingContainer) ,RepeaterItem)
Dim DivArrow As HtmlGenericControl = DirectCast(MenuItem.FindControl(MenuArrowDiv),HtmlGenericControl)
Dim getScreenName As Literal = DirectCast(MenuItem.FindControl(LtlMenuText),Literal)
Dim HdnFld As HiddenField = DirectCast(MenuItem.FindControl(HdnUrl),HiddenField)
Dim ListMenu As HtmlGenericControl = DirectCast(MenuItem.FindControl(LiMenu),HtmlGenericControl)
ResetStyle(RptMenu)
Dim getNaviga tionUrl As String = HdnFld.Value
Session(CurrentScreen)= getScreenName.Text
Response.Redirect(getNavigationUrl)
Catch ex As Exception
Dim ObjBlCommon As New BLCommon:ObjBlCommon .GoToErrorPage(ex)
End Try
End Sub

Private Sub ResetStyle(RptMenus As Repeater)
尝试
如果RptMenus.Items.Count> 0然后
For Each menutype As RepeaterItem In RptMenus.Items
Dim DivArrow As HtmlGenericControl = DirectCast(menutype.FindControl(MenuArrowDiv),HtmlGenericControl)
Dim ListMenu As HtmlGenericControl = DirectCast(menutype。 FindControl(LiMenu),HtmlGenericControl)
DivArrow.Style.Add(display,none)
ListMenu.Attributes.Remove(class)
Next
结束如果
Catch ex As Exception
Dim ObjBlCommon As New BLCommon:ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub

Protected Sub ImgBtnHome_Click( sender As Object,e As System.Web.UI.ImageClickEventArgs)Handles ImgBtnHome.Click
Dim objMobileBL As New BLMobileMaster,strPageTitle As String = Nothing,strPageUrl As String = Nothing
尝试
Dim dtbl作为New DataTable
dtbl = objMob ileBL.GetHomePageId(Session(current_user_id))
Session(Current_HomePage_Id)= dtbl.Rows(0)(Default_Home_AppAo_MobileWeb_Id)
如果Session(Current_HomePage_Id)> 0然后
Dim datatbl As New DataTable
datatbl = objMobileBL.GetHomePageDetails(Session(current_user_id))
strPageUrl = datatbl.Rows(0)(UserControl)
Session (CurrentScreen)= datatbl.Rows(0)(MobileWeb_Title)
Response.Redirect(strPageUrl,False)
Else
Dim dt As New DataTable
dt = objMobileBL .MySettingsDetails()
strPageTitle = dt.Rows(0)(MobileWeb_Title)
strPageUrl = dt.Rows(0)(UserControl)
Session(CurrentScreen)= strPageTitle
Response.Redirect(strPageUrl,False)
结束如果
Catch ex As Exception
Dim ObjBlCommon As New BLCommon:ObjBlCommon.GoToErrorPage(ex)
End Try
End Sub

受保护的子ImgBtnLogout_Click(发送者为对象,e为System.Web.UI.ImageClickEven tArgs)处理ImgBtnLogout.Click
尝试
Dim ObjBLPermission作为新的BLPermission
ObjBLPermission.PermissionCheck(SubModule,ACCESS,LOGOUT CLICK)
Session.Abandon()
Response.Redirect(〜/ Mobile / mSource / mLogin.aspx,False)
Catch ex As Exception
Dim ObjBlCommon As New BLCommon:ObjBlCommon.GoToErrorPage(ex)
结束尝试
结束子

私人子CheckRequest()
Dim objBLCommon作为新BLCommon:Dim Count As Integer,iAssignedCount As Integer = Nothing
尝试
如果会话(current_personnel_id)<> 然后
Count = objBLCommon.LoadRequestAssignedAndPendingCount(Session(current_personnel_id),待定)
结束如果
LnkBtntPending.Text = CStr(Count)& 待定
如果会话(current_personnel_id)<> 然后
iAssignedCount = objBLCommon.LoadRequestAssignedAndPendingCount(Session(current_personnel_id),Assigned)
结束如果
LnkBtnAssigned.Text = CStr(iAssignedCount)& 已分配
Catch ex As Exception
objBLCommon.GoToErrorPage(ex)
End Try
End Sub

受保护的子LnkBtntPending_Click(发送者为对象,e As System.EventArgs)处理LnkBtntPending.Click
DivPending.Style.Add(display,block)
DivAssigned.Style.Add(display,none)
RequestPending1 .InitializeScreen(Nothing,Nothing,Nothing,Nothing,Master)
End Sub

受保护的子LnkBtnAssigned_Click(发送者为对象,e为System.EventArgs)处理LnkBtnAssigned.Click
DivAssigned.Style.Add(display,block)
DivPending.Style.Add(display,none)
RequestAssigned1.InitializeScreen(Nothing,Nothing,Nothing,Nothing, Master)
End Sub

Public Sub HandlePendingCloseEventIn()
尝试
DivPending.Style.Add(display,none)
Catch ex As Exception
Dim objblcomm on As New BLCommon:objblcommon.GoToErrorPage(ex)
End Try
End Sub

Public Sub HandleAssignedCloseEventIn()
尝试
DivAssigned.Style.Add (display,none)
Catch ex As Exception
Dim objblcommon As New BLCommon:objblcommon.GoToErrorPage(ex)
End Try
End Sub
End类

javascript:

函数NumberOnly(e,Obj,BoolGrid){
var ObjCode =(document.all)? e.keyCode:e.which;
var ObjID = Obj.id; var UCntrlID =; var i = 0; var lblErrorID;
var IDArry = ObjID.split(_);
var ErrorObj = document.getElementById('lblErrorMessage')
if(ErrorObj!= null)lblErrorID ='lblErrorMessage';
else {
if(BoolGrid =='Grid1'){
for(i = 0; i< 5; i ++){
UCntrlID = UCntrlID + IDArry [i] +_;
}
}
else if(BoolGrid =='Grid2'){
for(i = 0; i< 3; i ++){
UCntrlID = UCntrlID + IDArry [i] +_;
}
}
else if(BoolGrid =='Grid3'){
for(i = 0; i< 2; i ++){
UCntrlID = UCntrlID + IDArry [i] +_;
}
}
else {
for(i = 0; i< IDArry.length - 1; i ++){
UCntrlID = UCntrlID + IDArry [i] +_;
}
}
lblErrorID = UCntrlID +'lblErrorMessage';
}
if(ObjCode> = 48&& ObjCode< = 57 || ObjCode == 32){
if(document.getElementById(lblErrorID)!= null)document .getElementById(lblErrorID).innerHTML =;
else if(document.getElementById('lblErrorMessage')!= null)document.getElementById('lblErrorMessage')。innerHTML =;
返回true;
}
else {
if(document.getElementById(lblErrorID)!= null)document.getElementById(lblErrorID).innerHTML =Please Please only only numbers;
else if(document.getElementById('lblErrorMessage')!= null)document.getElementById('lblErrorMessage')。innerHTML =Please Please only only numbers;
返回false;
}

}

解决方案

('#MenuDiv')。width();
var HeaderSubdiv = document.getElementById('HeaderSubdiv');
var ContentDiv = document.getElementById('DivContent');
var windowwidth =


(window).width();
HeaderSubdiv.style.width = windowwidth +'px';
ContentDiv.style.width = windowwidth +'px'
if(


('#MenuDiv')。is(':visible')){

Hi to All,
I developed mobile website.But JavaScript validation not working in mobile browser.Can you please give some idea to support JavaScript in mobile browser.Thanks for Advance.

<%@ Master Language="VB" CodeFile="mAtimsMaster.master.vb" AutoEventWireup="True"

    Inherits="Mobile_Source_mAtimsMaster" %>



<%@ Register TagPrefix="Uc1" TagName="RequestPending" Src="~/Mobile/mSource/mUserControls/mRequest/mRequestPending.ascx" %>
<%@ Register TagPrefix="Uc2" TagName="RequestAssigned" Src="~/Mobile/mSource/mUserControls/mRequest/mRequestAssigned.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width" initial-scale="1.0;" maximum-scale="1.0;"
        user-scalable="0;" />
    <meta name="HandheldFriendly" content="true" />
    <meta name="MobileOptimized" content="width" />
    <link href="../mStyles/mDefault.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function ShowHideMenu() {
            var MenuDiv = document.getElementById('MenuDiv');
            var menuWidth = $('#MenuDiv').width();
            var HeaderSubdiv = document.getElementById('HeaderSubdiv');
            var ContentDiv = document.getElementById('DivContent');
            var windowwidth = $(window).width();
            HeaderSubdiv.style.width = windowwidth + 'px';
            ContentDiv.style.width = windowwidth + 'px'
            if ($('#MenuDiv').is(':visible')) {
                $('#MenuDiv').hide();
                HeaderSubdiv.style.width = '99.8%';
                ContentDiv.style.width = '99.8%';
            }
            else {
                $('#MenuDiv').show();
                var height = $(document).height();
                $("#MenuDiv").each(function () {
                    $(this).css('min-height', height + 'px');
                });
                menuWidth = menuWidth - 15;
                $('.MenuArrowDiv').css('margin-left', menuWidth + 'px');
            }
        }
    </script>
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    
</head>
<body>
    <form id="form1"  runat="server">
 <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="~/Source/SCRIPTS/jquery191.js" />
            <asp:ScriptReference Path="~/Source/SCRIPTS/TextBoxValidate.js" />
            <%--     <asp:ScriptReference Path="~/Source/SCRIPTS/IE10Support.js" />--%>
        </Scripts>
    
    <div id="IMGDIV" style="display: none; font-family: Verdana, Arial, Helvetica, sans-serif;<br mode=" hold=" />        font-size: 11px; font-style: normal; position: absolute; width: 90%; height: 0%;<br mode=">
        <div style="width: 200px; text-align: center; margin: 0 auto;">
            <div style="width: 200px; height: 60px; float: left; text-align: center; border-style: inset;<br mode=" hold=" />                border-color: #444468; background-color: #E5F1FF; border-width: 3px; padding-bottom: 5px;">
                <div style="width: 180px; height: 45px; float: left; text-align: center; border-style: outset;<br mode=" hold=" />                    border-color: #E5F1FF; border-width: 10px;">
                    <font color="#444468" style="font-family: Times New Roman Baltic; font-size: x-large;<br mode=" hold=" />                        font-weight: bold; font-style: italic;">Processing...</font><br />
                    <asp:Image ID="ldimg" runat="server" ImageUrl="~/Source/Images/LoadingImg.gif" />
                </div>
            </div>
        </div>
    </div>
    <div id="MaskedDiv" class="MaskedDiv"  runat="server" clientidmode="Static">
    
    <div id="WholeDiv"  runat="server" clientidmode="Static" class="Page">
        <asp:HiddenField ID="HdnWindowWidth" runat="server" />
        <div id="MenuDiv"  runat="server" clientidmode="Static" style="width: auto; float: left;
            background-color: #1f2d3f; display: none;">
            <div style="width: auto; float: left; height: auto;">
                <div id="MenuTitleDiv"  runat="server" style="text-align: center; font-weight: bold;
                    font-size: medium; color: white; padding: 16px; border-bottom: 1px solid #300;">
                    ATIMS Mobile Web
                </div>
                <ul>
                    <asp:Repeater ID="RptMenu" runat="server" OnItemDataBound="RptMenu_ItemDataBound">
                        <itemtemplate>
                            <div id="MenuDivsub"  runat="server" style="cursor: pointer; margin-top: 5px; margin-left: -40px;
                                padding-left: 5px; padding-right: 15px;">
                                <li id="LiMenu"  runat="server" style="list-style-type: none; cursor: pointer; width: auto;
                                    font-size: medium;">
                                    <asp:LinkButton ID="LnkBtnMenu" runat="server" OnClick="LnkBtnMenu_Click" Style="text-decoration: none;">
                                        <asp:HiddenField ID="HdnUrl" runat="server" Value='<%#DataBinder.Eval(Container, "DataItem.UserControl")%>' />
                                        <span>
                                            <div id="DivMenuTitle"  runat="server" style="color: white; font-weight: bold; cursor: pointer;
                                                text-decoration: none; vertical-align: middle; padding-left: 5px;">
                                                <asp:Image ID="ImgMenu" runat="server" ImageAlign="AbsMiddle" />
                                                <asp:Literal ID="LtlMenuText" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.MobileWeb_Title")%>'>
                                            
                                        </span>
                                    
                                    <div id="MenuArrowDiv"  runat="server" class="MenuArrowDiv">
                                        <div class="Arrow-Left">
                                        </div>
                                    
                                
                            
                        </itemtemplate>
                    
                </ul>
            
        
        <div id="contentdiv"  runat="server" clientidmode="Static" style="overflow: hidden;">
            <div style="width: 100%; float: left; height: auto;">
                <div id="HeaderDiv"  runat="server" clientidmode="Static" style="height: auto; width: 99.8%;">
                    <div id="HeaderSubdiv"  runat="server" clientidmode="Static" style="float: left; width: 100%;
                        border: 1px solid #300;">
                        <div id="DivSystemSelect" style="float: left; width: auto; cursor: pointer;"  runat="server"
                             önclick="ShowHideMenu();">
                            <asp:Image ID="ImgBtnSysSelect" runat="server" ImageUrl="~/Mobile/mImages/mTop_SysSelect.bmp"
                                ToolTip="System Select" Style="width: auto; height: auto;" />
                        </div>
                        <div id="RequestDiv"  runat="server" style="width: auto; height: auto; text-align: left;
                            float: left; padding-top: 3px; padding-left: 3px; padding-right: 3px;">
                            <div style="width: auto; text-align: left; height: auto;">
                                <asp:LinkButton ID="LnkBtntPending" runat="server" Text="0 Pending" CssClass="HeaderMessageLink"> 
                            </div>
                            <div style="width: auto; text-align: left; height: auto;">
                                <asp:LinkButton ID="LnkBtnAssigned" runat="server" Text="0 Assigned" CssClass="HeaderMessageLink"> 
                            </div>
                        
                        <div id="ApplicationNameDiv"  runat="server" style="width: auto; height: auto; float: left;">
                            <div id="ApplnDiv"  runat="server" style="width: auto; height: auto; text-align: center;
                                line-height: 50px; vertical-align: middle; padding-left: 0.3em; position: relative;
                                margin: 0 auto;">
                                <asp:Label ID="LblApplication" runat="server" CssClass="HeaderLine1" Text="">
                            
                        
                        <div id="LogoutDiv"  runat="server" style="width: auto; height: auto; float: right;
                            cursor: pointer;">
                            <asp:ImageButton ID="ImgBtnLogout" runat="server" ToolTip="Logout" ImageAlign="AbsMiddle"
                                ImageUrl="~/Mobile/mImages/mLogout.png" Style="cursor: pointer;" />
                        
                        <div id="HomeDiv"  runat="server" style="width: auto; height: auto; float: right;
                            cursor: pointer;">
                            <asp:ImageButton ID="ImgBtnHome" runat="server" ToolTip="Go To Home Page" ImageAlign="AbsMiddle"
                                ImageUrl="~/Mobile/mImages/mTop_Home.bmp" />
                        
                    
                
                <div id="DivPending"  runat="server" style="width: 99%; float: left; height: auto;
                    position: absolute; display: none; background-color: White; border: 2px solid #00264D;">
                    <Uc1:RequestPending ID="RequestPending1"  runat="server" />
                
                <div id="DivAssigned"  runat="server" style="width: 99%; height: auto; float: left;
                    position: absolute; display: none; background-color: White; border: 2px solid #00264D;">
                    <Uc2:RequestAssigned ID="RequestAssigned1"  runat="server" />
                
                <div id="DivContent"  runat="server" clientidmode="Static" style="float: left; height: auto;
                    width: 99.8%;">
                    <asp:ContentPlaceHolder ID="MainContent" runat="server" />
                
            
        
    
    </form>
</body>
</html>


Code Behind
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Partial Class Mobile_Source_mAtimsMaster
    Inherits System.Web.UI.MasterPage
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            AddHandler RequestAssigned1.AssignedBack, AddressOf HandleAssignedCloseEventIn
            AddHandler RequestPending1.PendingBack, AddressOf HandlePendingCloseEventIn
            If Not IsPostBack Then
                Dim dt As New DataTable
                Dim objMobileBL As New BLMobileMaster
                dt = objMobileBL.GetApplicationModuleList()
                RptMenu.DataSource = dt
                RptMenu.DataBind()
                If Session("CurrentScreen") <> "" Then
                    LblApplication.Text = Session("CurrentScreen")
                Else
                    LblApplication.Text = "LandingPage"
                End If
            End If

            If Session("CurrentScreen") IsNot Nothing Then
                If RptMenu.Items.Count > 0 Then
                    For Each menutype As RepeaterItem In RptMenu.Items
                        Dim DivArrow As HtmlGenericControl = DirectCast(menutype.FindControl("MenuArrowDiv"), HtmlGenericControl)
                        Dim ListMenu As HtmlGenericControl = DirectCast(menutype.FindControl("LiMenu"), HtmlGenericControl)
                        Dim getMenuName As Literal = DirectCast(menutype.FindControl("LtlMenuText"), Literal)
                        ResetStyle(RptMenu)
                        If Session("CurrentScreen") = getMenuName.Text Then
                            DivArrow.Style.Add("display", "block")
                            ListMenu.Attributes.Add("class", "menu-title")
                            LblApplication.Text = Session("CurrentScreen")
                            Exit For
                        End If
                    Next
                End If
            End If
            CheckRequest()
        Catch ex As Exception
            Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
        End Try
    End Sub

    Protected Sub RptMenu_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RptMenu.ItemDataBound
        Try
            If e.Item.ItemType = ListItemType.AlternatingItem OrElse e.Item.ItemType = ListItemType.Item Then
                Dim imgMenu As Image = DirectCast(e.Item.FindControl("ImgMenu"), Image)
                Dim ltlText As Literal = DirectCast(e.Item.FindControl("LtlMenuText"), Literal)
                Select Case (ltlText.Text)
                    Case "My Settings"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mMySetting.png"
                    Case "My Console"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mMyConsole.png"
                    Case "Select Console"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mSelectConsole.png"
                    Case "My Housing"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mMyHousing.png"
                    Case "Select Housing"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mSelectHousing.png"
                    Case "My Locations"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mMyLocation.png"
                    Case "Search Locations"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mSearchLocation.png"
                    Case "My Last Inmate"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mLastInmate.png"
                    Case "Search Inmate"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mSearchInmate.png"
                    Case "Request Menu"
                        imgMenu.ImageUrl = "~/Mobile/mImages/mRequestMenu.png"
                End Select
            End If
        Catch ex As Exception
            Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
        End Try
    End Sub

    Protected Sub LnkBtnMenu_Click(sender As Object, e As System.EventArgs)
        Try
            Dim LnkBtnMenu As LinkButton = DirectCast(sender, LinkButton)
            Dim MenuItem As RepeaterItem = DirectCast(LnkBtnMenu.NamingContainer, RepeaterItem)
            Dim DivArrow As HtmlGenericControl = DirectCast(MenuItem.FindControl("MenuArrowDiv"), HtmlGenericControl)
            Dim getScreenName As Literal = DirectCast(MenuItem.FindControl("LtlMenuText"), Literal)
            Dim HdnFld As HiddenField = DirectCast(MenuItem.FindControl("HdnUrl"), HiddenField)
            Dim ListMenu As HtmlGenericControl = DirectCast(MenuItem.FindControl("LiMenu"), HtmlGenericControl)
            ResetStyle(RptMenu)
            Dim getNavigationUrl As String = HdnFld.Value
            Session("CurrentScreen") = getScreenName.Text
            Response.Redirect(getNavigationUrl)
        Catch ex As Exception
            Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
        End Try
    End Sub

    Private Sub ResetStyle(RptMenus As Repeater)
        Try
            If RptMenus.Items.Count > 0 Then
                For Each menutype As RepeaterItem In RptMenus.Items
                    Dim DivArrow As HtmlGenericControl = DirectCast(menutype.FindControl("MenuArrowDiv"), HtmlGenericControl)
                    Dim ListMenu As HtmlGenericControl = DirectCast(menutype.FindControl("LiMenu"), HtmlGenericControl)
                    DivArrow.Style.Add("display", "none")
                    ListMenu.Attributes.Remove("class")
                Next
            End If
        Catch ex As Exception
            Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
        End Try
    End Sub

    Protected Sub ImgBtnHome_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImgBtnHome.Click
        Dim objMobileBL As New BLMobileMaster, strPageTitle As String = Nothing, strPageUrl As String = Nothing
        Try
            Dim dtbl As New DataTable
            dtbl = objMobileBL.GetHomePageId(Session("current_user_id"))
            Session("Current_HomePage_Id") = dtbl.Rows(0)("Default_Home_AppAo_MobileWeb_Id")
            If Session("Current_HomePage_Id") > 0 Then
                Dim datatbl As New DataTable
                datatbl = objMobileBL.GetHomePageDetails(Session("current_user_id"))
                strPageUrl = datatbl.Rows(0)("UserControl")
                Session("CurrentScreen") = datatbl.Rows(0)("MobileWeb_Title")
                Response.Redirect(strPageUrl, False)
            Else
                Dim dt As New DataTable
                dt = objMobileBL.MySettingsDetails()
                strPageTitle = dt.Rows(0)("MobileWeb_Title")
                strPageUrl = dt.Rows(0)("UserControl")
                Session("CurrentScreen") = strPageTitle
                Response.Redirect(strPageUrl, False)
            End If
        Catch ex As Exception
            Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
        End Try
    End Sub

    Protected Sub ImgBtnLogout_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImgBtnLogout.Click
        Try
            Dim ObjBLPermission As New BLPermission
            ObjBLPermission.PermissionCheck("SubModule", "ACCESS", "LOGOUT CLICK")
            Session.Abandon()
            Response.Redirect("~/Mobile/mSource/mLogin.aspx", False)
        Catch ex As Exception
            Dim ObjBlCommon As New BLCommon : ObjBlCommon.GoToErrorPage(ex)
        End Try
    End Sub

    Private Sub CheckRequest()
        Dim objBLCommon As New BLCommon : Dim Count As Integer, iAssignedCount As Integer = Nothing
        Try
            If Session("current_personnel_id") <> "" Then
                Count = objBLCommon.LoadRequestAssignedAndPendingCount(Session("current_personnel_id"), "Pending")
            End If
            LnkBtntPending.Text = CStr(Count) & " Pending"
            If Session("current_personnel_id") <> "" Then
                iAssignedCount = objBLCommon.LoadRequestAssignedAndPendingCount(Session("current_personnel_id"), "Assigned")
            End If
            LnkBtnAssigned.Text = CStr(iAssignedCount) & " Assigned"
        Catch ex As Exception
            objBLCommon.GoToErrorPage(ex)
        End Try
    End Sub

    Protected Sub LnkBtntPending_Click(sender As Object, e As System.EventArgs) Handles LnkBtntPending.Click
        DivPending.Style.Add("display", "block")
        DivAssigned.Style.Add("display", "none")
        RequestPending1.InitializeScreen(Nothing, Nothing, Nothing, Nothing, "Master")
    End Sub

    Protected Sub LnkBtnAssigned_Click(sender As Object, e As System.EventArgs) Handles LnkBtnAssigned.Click
        DivAssigned.Style.Add("display", "block")
        DivPending.Style.Add("display", "none")
        RequestAssigned1.InitializeScreen(Nothing, Nothing, Nothing, Nothing, "Master")
    End Sub

    Public Sub HandlePendingCloseEventIn()
        Try
            DivPending.Style.Add("display", "none")
        Catch ex As Exception
            Dim objblcommon As New BLCommon : objblcommon.GoToErrorPage(ex)
        End Try
    End Sub

    Public Sub HandleAssignedCloseEventIn()
        Try
            DivAssigned.Style.Add("display", "none")
        Catch ex As Exception
            Dim objblcommon As New BLCommon : objblcommon.GoToErrorPage(ex)
        End Try
    End Sub
End Class

javascript:

function NumberOnly(e, Obj, BoolGrid) { 
    var ObjCode = (document.all) ? e.keyCode : e.which;
    var ObjID = Obj.id; var UCntrlID = ""; var i = 0; var lblErrorID;
    var IDArry = ObjID.split("_");
    var ErrorObj = document.getElementById('lblErrorMessage')
    if (ErrorObj != null) lblErrorID = 'lblErrorMessage';
    else {
        if (BoolGrid == 'Grid1') {
            for (i = 0; i < 5; i++) {
                UCntrlID = UCntrlID + IDArry[i] + "_";
            }
        }
        else if (BoolGrid == 'Grid2') {
            for (i = 0; i < 3; i++) {
                UCntrlID = UCntrlID + IDArry[i] + "_";
            }
        }
        else if (BoolGrid == 'Grid3') {
            for (i = 0; i < 2; i++) {
                UCntrlID = UCntrlID + IDArry[i] + "_";
            }
        }
        else {
            for (i = 0; i < IDArry.length - 1; i++) {
                UCntrlID = UCntrlID + IDArry[i] + "_";
            }
        }
        lblErrorID = UCntrlID + 'lblErrorMessage';
    } 
    if (ObjCode >= 48 && ObjCode <= 57 || ObjCode == 32) {
        if (document.getElementById(lblErrorID) != null)   document.getElementById(lblErrorID).innerHTML = " "; 
        else if (document.getElementById('lblErrorMessage') != null)    document.getElementById('lblErrorMessage').innerHTML = " "; 
        return true;
    }
    else {
        if (document.getElementById(lblErrorID) != null)  document.getElementById(lblErrorID).innerHTML = "Please Enter  only numbers"; 
        else if (document.getElementById('lblErrorMessage') != null)  document.getElementById('lblErrorMessage').innerHTML = "Please Enter  only numbers"; 
        return false;
    }

}

解决方案

('#MenuDiv').width(); var HeaderSubdiv = document.getElementById('HeaderSubdiv'); var ContentDiv = document.getElementById('DivContent'); var windowwidth =


(window).width(); HeaderSubdiv.style.width = windowwidth + 'px'; ContentDiv.style.width = windowwidth + 'px' if (


('#MenuDiv').is(':visible')) {


这篇关于为什么javascript不支持移动浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆