在firefox浏览器中使用jquery不更改iframe源代码 [英] iframe source is not changed using jquery in firefox browser

查看:67
本文介绍了在firefox浏览器中使用jquery不更改iframe源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Asp.net,我有一个包含2个iFrame的主页面。

首先iFrame就像一个菜单,其中每个项目都是一个链接(一个href)。

第二帧是显示与点击的项目对应的aspx页面。



我在使用IE时点击href项目成功更新了第二帧源和Chrome浏览器,但问题是使用Firefox 24.0浏览器的点击事件没有发生任何事情,我尝试了多种方法使其工作,但没有任何效果。

请帮忙。



主页代码:

Hi, I'm using Asp.net, I have a main page containing 2 iFrames.
First iFrame is like a menu where each item is a link(a href).
Second frame is to display the aspx page corresponding to the clicked item.

I successfully updated the second frame source on click of href items while using IE and Chrome browsers, but the problem is that nothing is happening on click event using Firefox 24.0 browser, I tried more than one method to make it work, but nothing worked.
Please help.

Main Page code:

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<table style="height:99%;width:100%">
    <tr>
        <td style="height:100%;width:18%">
            <iframe seamless src="HelpMenu.aspx" style="height: 99%; width: 99%;overflow:hidden;"></iframe>
        </td>
        <td style="height:100%;width:82%">
            <iframe id="contentFrame" seamless src="Introduction.aspx" style="height: 99%; width: 99%;overflow:hidden;border-right:none hidden;"></iframe>
        </td>
    </tr>
</table>
</asp:Content>





我用来更改帧源的功能代码:





code of function i used to change frame source:

    <asp:Content ID="AfterScript" ContentPlaceHolderID="ContentAfterScript" runat="server">
    <script type="text/javascript">
        $(window).ready(function () {
            $("a.x-tree-node-anchor").click(function (event) {
                event.preventDefault();

                var pageUrl = this.text + '.aspx'
                pageUrl = pageUrl.replace(' ', '')

                loadIframe('contentFrame', pageUrl);
            });

            function loadIframe(iframeName, url) {
                var $iframe = $('#' + iframeName);

                $iframe.attr('src', url);
                top.frames["contentFrame"].location = url;

                //The document.getElementById method returns an error that this is an undefined object, which is really weird !!
                //document.getElementById('contentFrame').setAttribute('src', url);
                //document.getElementById(iframeName).contentWindow.location.reload(true);
                return false;
            }
        });
    </script>
    </asp:Content>

推荐答案

window )。ready( function (){
(window).ready(function () {


ax-tree-node-anchor)。click( function (事件){
event.preventDefault();

var pageUrl = this .text + ' .aspx'
pageUrl = pageUrl.replace(< span class =code-string>' '' '

loadIframe(' contentFrame',pageUrl);
});

function loadIframe(iframeName,url){
var
("a.x-tree-node-anchor").click(function (event) { event.preventDefault(); var pageUrl = this.text + '.aspx' pageUrl = pageUrl.replace(' ', '') loadIframe('contentFrame', pageUrl); }); function loadIframe(iframeName, url) { var


iframe =


这篇关于在firefox浏览器中使用jquery不更改iframe源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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