Загрузить ifame onclick и событие KeyPress

0

У меня есть вкладки на моей странице aspx, в настоящее время я разработал ее для загрузки onclick-события. Я пытаюсь загрузить его на событие нажатия клавиши. Событие нажатия клавиши не срабатывает, если я пытаюсь перейти вниз/вверх стрелки, вкладки перемещаются. Может ли кто-нибудь помочь в ot.

         <%@ Page Title="" Language="C#" MasterPageFile="~/NIT.Master" AutoEventWireup="true" CodeBehind="Initiative.aspx.cs" Inherits="NIT_AMPO.Initiative" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<title>Initiative</title>
<script type="text/jscript" >
    $(function () {
        $("#tabs").tabs().addClass("ui-tabs-vertical ui-helper-clearfix");
    });       
   $(document).ready(function () {
       if ('<%=Session["ProjectID"]%>' != "") {
           $('#Contacts').attr('href', '#ContactsPage');
           $('#Comments').attr('href', '#CommentsPage');
           $('#RiskSummary').attr('href', '#RiskAssessmentSummaryPage');
           $('#RiskAssessment').attr('href', '#tabs-3');
           $('#Approvals').attr('href', '#tabs-3');
           $('#Task').attr('href', '#tabs-3');
           $('#Documents').attr('href', '#tabs-3');
           $('#PostLaunch').attr('href', '#tabs-3');
           $('#LinkedInititatives').attr('href', '#tabs-3');
       }
       else {
           $('#Contacts').prop('disabled', true); ;
           $('#Comments').prop('disabled', true);
           $('#RiskSummary').prop('disabled', true);
           $('#RiskAssessment').prop('disabled', true);
           $('#Approvals').prop('disabled', true);
           $('#Task').prop('disabled', true);
           $('#Documents').prop('disabled', true);
           $('#PostLaunch').prop('disabled', true);
           $('#LinkedInititatives').prop('disabled', true);
       }
   });
</script>

<script type="text/javascript">
    function loadIframe(iframeName, url) {
        var $iframe = $('#' + iframeName);
        if ($iframe.length) {
            $iframe.attr('src', url);
            return false;
        }
        return true;
    }
    function refreshPage() {
        //document.getElementById("ifrm").contentWindow.location.reload(true);
        document.getElementById("ifrm").contentWindow.location.href = document.getElementById("ifrm").contentWindow.location.href
    }
    function iframeLoaded() {
        var iFrameID = document.getElementById('ifrm');
        if (iFrameID) {
            iFrameID.height = "";
            var height = iFrameID.contentWindow.document.body.scrollHeight
            if (height < 600) {
                iFrameID.height = "600px";
            }
            else {
                iFrameID.height = height + "px";
            }
        }
    }
    function iframeBlur() {
        window.focus();
    }

    $(function () {
        $('a:first').focus
        var id = $('a:first').focus();
    });

    $(document).on('keydown', function (e) {
        if (e.which == 40) {
            id = $("*:focus");
            id.parents('li').next().find('a').focus();
        }
        else if (e.which == 38) {
            id = $("*:focus");
            id.parents('li').prev().find('a').focus();

        }
    });
</script>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div id="tabs">
    <ul>    
        <li><a id="Main" href="#iframeInitiative" onclick="return loadIframe('ifrm', 'Main.aspx')">Main</a></li>
        <li><a id="Contacts"  href="#iframeInitiative" onclick="return loadIframe( 'ifrm', 'Contacts.aspx')" onfocus="return loadIframe( 'ifrm', 'Contacts.aspx')">Contacts</a></li>
        <li><a id="Comments" href="#iframeInitiative" onclick="return loadIframe( 'ifrm', 'Comments.aspx')" onfocus="return loadIframe( 'ifrm', 'Comments.aspx')">Comments</a></li>
        <li><a id="RiskSummary" href="#iframeInitiative" onclick="return loadIframe('ifrm', 'RiskAssessmentSummary.aspx')" onfocus="return loadIframe( 'ifrm', 'RiskAssessmentSummary.aspx')">Risk Assessment Summary</a></li>
        <li><a id="RiskAssessment" href="#iframeInitiative" onclick="return loadIframe('ifrm', 'RiskAssessment.aspx')">Risk Assessment</a></li>
        <li><a id="Approvals" href="#iframeInitiative" onclick="return loadIframe('ifrm', 'Approvals.aspx')">Approvals</a></li>
        <li><a id="Task" href="#iframeInitiative" onclick="return loadIframe('ifrm', 'ImpactTaskSummary.aspx')">Impact/Task Summary</a></li>
        <li><a id="Documents" href="#iframeInitiative" onclick="return loadIframe('ifrm', 'Documents.aspx')">Documents</a></li>
        <li><a id="PostLaunch" href="#iframeInitiative"  onclick="return loadIframe('ifrm', 'PostLaunch.aspx')">Post Launch</a></li>
        <li><a id="LinkedInititatives" href="#tabs-3">Linked Initiatives</a></li>
    </ul>
    <div id="tabs-3">      
            <div id="left">
                <img id="Logo" src="Images/Website_Page_Under_Construction.jpg" alt="AmEx Logo" height="200" width="200" />
            </div>
        </div>
        <div id="iframeInitiative">
            <iframe name="ifrm" id="ifrm" src="Main.aspx" frameborder="0" width="900px" onload="iframeLoaded()" >
            </iframe>
        </div>
</div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadWindowManager ID="ParentRadWindowManager1" runat="server" EnableShadow="true" Behaviors="Close"
    Style="z-index: 7000">
    <Windows>
        <telerik:RadWindow ID="RiskQuestionnaireDialog" runat="server" ReloadOnShow="true" VisibleStatusbar="false"
            ShowContentDuringLoad="false" Modal="true" BorderStyle="None" Height="560" Width="1000" OnClientClose="refreshPage">
        </telerik:RadWindow>
        <telerik:RadWindow ID="ImpactDetailsDialog" runat="server" ReloadOnShow="true" Height="540" Width="700" OnClientClose="refreshPage"
            ShowContentDuringLoad="false" Modal="true" BorderStyle="None" VisibleStatusbar="false">
        </telerik:RadWindow>
        <telerik:RadWindow ID="SendMailDialog" runat="server" ReloadOnShow="true" Height="460" Width="800" VisibleStatusbar="false"
            ShowContentDuringLoad="false" Modal="true" BorderStyle="None">
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>

Теги:

1 ответ

0

Попробуйте использовать onfocus вместо onkeypress

как это

<li><a id="Contacts"  href="#iframeInitiative" onclick="return loadIframe( 'ifrm', 'Contacts.aspx')" onfocus="return loadIframe( 'ifrm', 'Contacts.aspx')">Contacts</a></li>

добавить этот код

код

  $(function(){
    $('a:first').focus
    var id=$('a:first').focus();
});
$(document).on('keydown',function(e)
   {
       if(e.which==40)
       {
          id=$("*:focus");
          id.parents('li').next().find('a').focus();
       }
       else if(e.which==38)
       {
           id=$("*:focus");
           id.parents('li').prev().find('a').focus();

       }
 });

Рабочий ДЕМО

  • 0
    OnFocus не работает ... Еще одно предложение?
  • 0
    @saravanakumarr Вы должны сосредоточить вкладки, попробуйте с помощью клавиши вкладок, чтобы перемещаться по вашим вкладкам
Показать ещё 10 комментариев

Ещё вопросы

Сообщество Overcoder
Наверх
Меню