小编los*_*ens的帖子

iframe中的AngularJS ng-src

我在iframe中使用ng-src时遇到问题.我需要这样做:

<div class="tab-content">
        <ul class="nav nav-tabs" ng-repeat="document in issues.Document">
            <div class="tab-pane pdf-height col-md-5 padding_0" id="{{document.name}}">
                <iframe ng-src="http://192.168.223.110/cat/{{document.directory}}/{{document.name}}.{{document.type}}" height="100%" width="100%"></iframe>                    
            </div>
        </ul>
    </div>
Run Code Online (Sandbox Code Playgroud)

结果:

<iframe ng-src="http://192.168.223.110/cat/{{document.directory}}/{{document.name}}.{{document.type}}" height="100%" width="100%" src="http://192.168.223.110/cat/{{document.directory}}/{{document.name}}.{{document.type}}"></iframe>
Run Code Online (Sandbox Code Playgroud)

我知道问题是$ sce,这是对XSS的保护,并且链接需要添加到白名单......所以当我这样做时它正在工作.

<ul class="nav nav-tabs" ng-repeat="document in issues.Document">
    <div class="tab-pane pdf-height col-md-5 padding_0" id="{{document.name}}">
         <iframe ng-src="{{someUrl}}" height="100%" width="100%"></iframe>                    
     </div>
</ul>
Run Code Online (Sandbox Code Playgroud)

我在控制器内部定义:

$rootScope.someUrl = $sce.trustAsResourceUrl('http://192.168.223.110/cat/files/incoming/12345_3232ASD_pero.pdf');
Run Code Online (Sandbox Code Playgroud)

但我不能这样做因为我用ng-repeat循环,所以链接是动态生成的.它需要从数据库中读取!

javascript iframe angularjs

30
推荐指数
2
解决办法
4万
查看次数

试图理解js中窗口和文档对象之间的区别

我试图理解js中窗口和文档对象之间的区别.我在网上查了一下,但我还是没有清楚的了解.据我所知:窗口就像一个超级文档,它包含了文档对象.所以,如果我使用firefox打开一个页面:localhost/test.js,我可以说浏览器:firefox是window对象,文件test.js是文档对象吗?

javascript

11
推荐指数
2
解决办法
2万
查看次数

javascript:检查iframe网址是否是同一个域或外部的东西

我知道我无法访问iframe中的数据,该iframe显示来自其他域的页面.这非常好,但我想检测一下,iframe当前是显示来自我的域的页面还是外部的.

我的第一次尝试是尝试访问

$('iframe')[0].contentWindow.document
Run Code Online (Sandbox Code Playgroud)

包装try {} catch {},并且如果抛出错误,则意味着我无法访问它,因此iframe页面必须是外部的.这听起来像一个完美的解决方案,但事情是safari发布了一个"不安全的JavaScript尝试访问带URL的帧"消息到javascript控制台.这不仅是丑陋的,还可能导致其他或未来的浏览器向用户显示明确的安全警告?

javascript iframe same-origin-policy

9
推荐指数
1
解决办法
3906
查看次数

如何在使用Spring MVC时使用send.redirect()

我试图从Interceptor和Handler Mapping程序重定向到动态页面.我已经定义了一个控制器,它通过模型处理和重定向(/hello.htm)(我的程序中只有这个控制器).在此之前,它工作正常.除此之外,我注册了一个处理程序,一旦满足某些条件,它将重定向到页面.

public class WorkingHoursInterceptor extends HandlerInterceptorAdapter  {
@Override
public boolean preHandle(HttpServletRequest request,
        HttpServletResponse response, Object handler) throws Exception {
    System.out.println("In Working Hours Interceptor-pre");
    Calendar c=Calendar.getInstance();
    if(c.get(Calendar.HOUR_OF_DAY)<10||c.get(Calendar.HOUR_OF_DAY)>20){
        response.sendRedirect("/WEB-INF/jsp/failure.jsp");
                        return false;
    }
    return true;
..............
..............
} 
Run Code Online (Sandbox Code Playgroud)

但是,一旦涉及到response.sendRedirect它,即使提到的页面存在,它也显示未找到的资源.我试图重定向到"WEB-INF/jsp/hello.jsp"但仍然显示相同的错误.如果不满足拦截器中的条件,则程序正常.

下面显示了程序中唯一存在的控制器.

@Controller
public class MyController {
@RequestMapping("/hello.htm")
public ModelAndView sayGreeting(){
    String msg="Hi, Welcome to Spring MVC 3.2";
    return new ModelAndView("WEB-INF/jsp/hello.jsp","message",msg);

    }

}
Run Code Online (Sandbox Code Playgroud)

(hello.html如果改变拦截器条件,处理控制器工作正常)

如果我只是在控制台中打印一条消息,该程序可以正常工作,而不是重定向.但是一旦涉及到重定向,就会显示错误.我是否需要指定一个单独的控制器来处理此请求?这个重定向请求会转到dispatcher-servlet吗?

redirect spring spring-mvc

6
推荐指数
1
解决办法
1万
查看次数

在apache配置上使用查询字符串设置引用标头

我需要从查询字符串中获取一个参数,并将其设置在Apache配置文件的referrer头中.你知道这是否可行?

我能够对cookie做同样的事情,但我需要使用查询字符串.

setEnvIfNoCase ^Cookie$ "(referrer=\w*:\/\/\w*)" HTTP_MY_COOKIE=$1
setEnvIfNoCase HTTP_MY_COOKIE "(http:\/\/.*\.\w*)" REFERRER=$1
RequestHeader set Referer %{REFERRER}e
Run Code Online (Sandbox Code Playgroud)

问候

apache http apache2 referrer

2
推荐指数
1
解决办法
5783
查看次数

Internet Explorer 10破字不起作用

如果更改,我希望文本相应地包装到表的宽度.除了IE 10,我的CSS无处不在(Firefox,Chrome,甚至其他版本的IE).

这是HTML代码:

<div class="container">
  <table class="table">
    <tbody class="tBody">
      <tr>
       <td>
          <span class="spanClass">
             <img src="image.png">
              <a href="">This is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrryyyyy long
                      text that doesnt work like I want it to. I hate IE.
              </a>
           </span>
         </td>
       </tr>
    </tbody>
  </table>
</div>
Run Code Online (Sandbox Code Playgroud)

这是CSS:

.container {
  white-space: pre-wrap;
  display: inline-table;
  word-wrap: break-word; 
  word-break: break-all;
 }

 table {
  width:100%;
  table-layout:fixed;
 }

.spanClass {
  display: inline-flex;
 }
Run Code Online (Sandbox Code Playgroud)

我注意到.spanClass规则可能会干扰我想要的,但我需要这个规则来保持<img><a>元素在其他浏览器中正确对齐.

html css internet-explorer-10

2
推荐指数
2
解决办法
5644
查看次数

CSS:&lt;tbody&gt;宽度比&lt;table&gt;宽度宽。文字没有换行

我有以下HTML代码:

<div class="container">
  <table class="table">
    <tbody class="tBody">
      <tr>
        <td>Hellooooooooooooooooooooooooooooooooooooooooooooo</td>
        <td>World</td>
      </tr>
    </tbody>
  </table>
</div>
Run Code Online (Sandbox Code Playgroud)

和CSS:

.container {width: 100%;}
.table {display:block;}
.tBody {max-width: inherit;}
Run Code Online (Sandbox Code Playgroud)

我的问题是总宽度是由拖动栏定义的,因此所有元素的宽度都必须是动态的。我希望<td>元素内的文本能够动态地自动换行。到目前为止,<div>的宽度根据拖动栏的位置更改其值。为了使其具有<div>的宽度,我将<table>CSS 设置为display:block。在表中的元素的其余部分,<tbody><tr><td>,它们的宽度设置为在表中的最宽的元件,在这种情况下是文字“Hellooooooooooooooooooooooooooooooooooooooooo”。因此,现在,如果我移动拖动栏以尝试使表格变小,div则会更改其宽度,但表格元素的宽度将保持不变。文本也不会换行。

如何通过拖动栏设置表格(及其子表格)的宽度?

html css

1
推荐指数
1
解决办法
2277
查看次数