小编Fre*_*rik的帖子

Javascript在iframe中使用replace方法

我想知道是否可以替换一个内部的突然单词iframe.

我已经使用jQuery来改变内容iframe相同的内容,但有替换.这里的问题是'光标重置'到输入字段的开头,所以你必须重新开始写.

所以这就是我所做的

<html>
<head>
<script>
function iFrameOn(){
    richTextField.document.designMode = 'On';
}

</script>
</head>
<body onLoad="iFrameOn();">

<!-- Hide(but keep)your normal textarea and place in the iFrame replacement for it -->
<textarea style="display:none;" name="myTextArea" id="myTextArea" cols="100" rows="14"></textarea>
<iframe name="richTextField" id="richTextField" style="border:#000000 1px solid; width:100px; height:20px;">
</iframe>
<!--End replacing your normal textarea -->
</p>
<script>
      function ReplaceWords(){
          var textfield = document.getElementById("richTextField");

          textfield.contentWindow.document.body.onkeyup = function(e){
              var content   = textfield.contentWindow.document.body.innerHTML;
              var Fixed_Content = content.replace("hey", "yo");
              $(document).ready(function() {
                  $('#richTextField').contents().find('body').html(Fixed_Content);
              });
          }; …
Run Code Online (Sandbox Code Playgroud)

html javascript iframe jquery replace

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

在网络选项卡下的检查器中没有看到来自某个网​​站的所有流量?

因此,当我访问诸如https://coinmarketcap.com(显示加密货币的价格)之类的网站时,在我的 Chrome 浏览器中,我似乎没有在“网络”选项卡下的检查器中看到所有活动。

这是一个可视化网站的屏幕截图: 在此处输入图片说明

我看到价格在网站上实时更新(没有刷新),但我在网络检查器中没有看到任何活动。

当我第一次加载页面时当然有活动,但之后即使网站动态更新价格也没有任何活动?我的第一个想法是,它可能是通过客户端的 JS 脚本进行的虚假更新,但我知道有很多网站你看不到这个,那么这里发生了什么?使用什么类型的协议来实现这一点,因为我知道 WebSockets 和轮询 (xhr) 总是会出现。

网络检查器的屏幕截图,请清楚我的意思(显示前 50 毫秒(加载时间)的流量,然后什么都不显示) 在此处输入图片说明

networking google-chrome web-inspector

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

Python在转到else语句之前检查整个循环

else如果if条件为假,我如何运行整个循环然后转到语句?

输出是:

没有

没有

但是如果所有值都不相等,我只希望它跳转到else语句!

test_1 = (255, 200, 100)
test_2 = (200, 200, 100)
test_3 = (500, 50, 200)

dict = {"test_1":test_1,
        "test_2":test_2,
        "test_3":test_3}


for item in dict:
   if dict[item] == (500, 50, 200):
        print('Yes')
   else:
        print('No')
Run Code Online (Sandbox Code Playgroud)

所以基本上输出应该说,因为其中一个值是真的.

python loops if-statement

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

打印数字时添加千位分隔符

我真的不知道这个问题的"名称",所以它可能是一个不正确的标题,但问题很简单,如果我有一个数字

例如:

number = 23543
second = 68471243
Run Code Online (Sandbox Code Playgroud)

我想这样做print().

23543
68471243

我希望这解释得足够或者添加评论.任何帮助表示赞赏!

python optimization numbers decimal

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

在“for 循环语句”中使用“not”

  1. 为什么不能not在语句中使用 a for?假设 和object都是list迭代的

  2. 如果你做不到,还有其他方法吗?

这是一个示例,但“显然”存在语法错误:

tree = ["Wood", "Plank", "Apples", "Monkey"]

plant = ["Flower", "Plank", "Rose"]

for plant not in tree:
    # Do something
    pass 
else:
    # Do other stuff
    pass
Run Code Online (Sandbox Code Playgroud)

python for-loop if-statement

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