相关疑难解决方法(0)

如何防止Chrome在查看源代码时刷新页面?

在 Google Chrome 中查看页面源代码时,浏览器会打开一个新选项卡,并基本上将带有view-source:前缀的 URL 粘贴到其中。这是不可取的。

作为开发人员,我可能会包含一些仅在提交表单后在源中可见的诊断输出。当 Chrome 刷新页面以查看源时,它会使此信息消失。

有没有办法阻止这种行为?

注意:我熟悉“检查元素”选项。这不是查看您正在查看的确切页面的原始页面源的适当替代品。


快速测试脚本

<pre>
  <?= print_r($_POST, true) ?>
</pre>
<form action="" method="post">
  <input id="foo" name="foo" value="bar" />
  <input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)

点击提交按钮后,页面显示

Array
(
    [foo] => bar
)
Run Code Online (Sandbox Code Playgroud)

如果查看页面源代码,您将看到一个 $_POST输出

<pre>
Array
(
)
</pre>
<form action="" method="post"> 
  <input id="foo" name="foo" value="bar" /> 
  <input type="submit" /> 
</form> 
Run Code Online (Sandbox Code Playgroud)

更新

显然这个bug已经提交了。叹...

如果有人知道一个好的工作,我将不胜感激。

google-chrome web-development diagnostic debug

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