快速测试浏览器兼容性的 JavaScript 代码片段

发布于 2024-09-10 03:57:22 字数 504 浏览 1 评论 0原文

正如我们使用 http://www.sliver.com/dotnet/SnippetCompiler/(链接于 2021 年 4 月 24 日处于非活动状态)来快速测试 C# 代码一样,我也可以对 javascript 执行相同的操作在 chrome 调试器工具和 Firebug (firefox) 中。

我对一个工具或一些在线工具更感兴趣,它可以运行一小段 javascript 并判断它是否可以在主流浏览器中正常运行以及结果。

更新:
我是开发人员而不是测试人员。我不想在我的电脑上安装所有浏览器。我喜欢 chrome,只需单击 Ctrl+Shift+J 并将我的 javascript 粘贴到其控制台中,我就可以在 chrome 中快速调试/测试(语法/结果)几乎所有 javascript。但这只是测试它是否可以在 Chrome 中运行。我现在对创建图书馆不感兴趣。 Google 和 Stackoverflow 帮助我非常快速地获得针对特定任务的最好和最新的 javascript。

Just as we have http://www.sliver.com/dotnet/SnippetCompiler/ (link inactive on 2021-04-24) to test a C# code quickly, I can also do the same for javascript in chrome debugger tools and Firebug (firefox).

I would be more interested in a tool or some online tool which can run a small piece of javascript and tell if it properly runs in prominent browsers and the result.

UPDATE:
I'm a developer and not tester. I don't want to install all browsers on my PC. I like chrome and I can debug/test (for syntax/result) almost every javascript quickly in chrome by just clicking Ctrl+Shift+J and pasting my javascript in its console. But that will just test if it works in chrome. I'm not interested in creating a library right now. Google and Stackoverflow helps me get the greatest and latest javascript for a specific task very quickly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

川水往事 2024-09-17 03:57:22

我找到了一种方法。但它不是那么快,仍然想知道更好的答案。可能是某种可以做到这一点的工具。

一种方式:-
JsBin 上编写 try-catch 块中包含的 javascript 并创建其公共链接。现在使用 BrowserShots 检查您的链接。

使用 javascript(有条件地)编写大量 html,以便能够看到 BrowserShots 给出的图像上的差异。

I found one way. But it is not that quick and still would like to know better answer. May be some kind of tool which can do this.

One Way:-
Write your javascript enclosed in try-catch block on JsBin and create its public link. Now check your link with BrowserShots.

Write considerable amount of html (conditionally) using javascript to be able to see the difference on Images given by BrowserShots.

寂寞笑我太脆弱 2024-09-17 03:57:22

提出 10 年后的另一个选择:我建议使用 JSHint 来实现这一点。

当您导航到他们的网站时,第一页允许您简单地粘贴 JS 片段并获取有关从可能令人困惑的语法到“最低 ES 版本”警告的所有信息。

此外,您还可以将 JSHint 安装到您的项目中,并使用命令手动运行或插入现有的构建链中,以使用自定义规则在本地执行相同的操作。

To propose another option 10 years down the line: I would suggest using JSHint for this.

The first page as you navigate to their site allows you to simply paste a JS snippet and get information regarding everything from potentially confusing syntax to "minimum ES version" warnings.

Furthermore, you can also install JSHint to your project and have a command to either run manually or slot into your existing build chain to do the same thing locally with custom rules.

奶茶白久 2024-09-17 03:57:22

我还找到了这个工具:JS Compatibility Checker,它基于我可以使用
可能会有所帮助,但不会概述每个问题。

I've also found this tool: JS Compatibility Checker, which is based on Can I use.
Could be helpful, but won't outline every issue.

×纯※雪 2024-09-17 03:57:22

您可以轻松地创建一个测试页面来容纳您的代码片段,然后在目标浏览器中尝试它们。这样做的另一个好处是为您创建的片段提供一个中央库,因此您不必在整个目录中寻找您在 2010 年创建的那个很酷的小部件。

You can easily make a test page to house your snippets, then try them in your target browsers. That has the added advantage of providing a central library for the snippets you do create, so you don't have to go hunting through entire directories looking for that cool little widget you created back in 2010.

花心好男孩 2024-09-17 03:57:22

此外,您还可以检查 MDN Web 文档浏览器兼容性部分,如果该界面可用(例如 window.location - https://developer.mozilla.org/en-US/docs/Web/API/Location#browser_compatibility)

Also, you can check the MDN Web Docs Browser Compatibility section if that interface is available (Eg. window.location - https://developer.mozilla.org/en-US/docs/Web/API/Location#browser_compatibility)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文