链接到页面中的框

时间:2014-11-09 15:00:00

标签: html css hyperlink box

我通常会在某些网站上看到一个垂直导航菜单,这些链接会应用于页面中的一个框,但不会应用于<iframe>标记。 有谁可以帮忙。 谢谢你

1 个答案:

答案 0 :(得分:1)

我认为你试图在没有刷新页面的情况下告诉加载div。我们将其称为Gmail等单页应用程序。你可以通过多种方式完成这项工作。

  1. 通过调用ajex并从主机加载div来手动执行此操作。所有事件都由单独的JS函数处理。
  2. 尝试框架。

    *像struct2这样的后端框架具有此功能,因此您必须在后端编码此方法

    * angularjs支持路由功能等前端框架可以实现此结果。所以这次你必须在前端处理JS。

  3. 角度js中的示例

    var app = angular.module( "myApp", [] );
    
    app.config( function ( $routeProvider ) {
      $routeProvider
        .when( '/this', { templateUrl: 'this.html' } )
        .when( '/that', { templateUrl: 'that.html' } )
        .when( '/other', { templateUrl: 'other.html' } )
        .otherwise( { redirectTo: '/this' } );
    });
    
    app.controller( 'MainCtrl', function ( $scope ) {
    });
    <script type="text/ng-template" id="this.html">
      This Page.
    </script>
    <script type="text/ng-template" id="that.html">
      That Page.
    </script>
    <script type="text/ng-template" id="other.html">
      Other Page.
    </script>
    
    <div ng-controller="MainCtrl">
      <ul>
        <li><a href="#/this">This</a></li>
        <li><a href="#/that">That</a></li>
        <li><a href="#/other">Other</a></li>
      </ul>
      <ng-view></ng-view>
    </div>

    j小提琴代码&gt;&gt; http://jsfiddle.net/joshdmiller/NEuJ6/