[英]How to execute a piece of JavaScript code using Chrome developer tools
I use Google Chrome and its developer tools like ' Inspect element ' to check performance of my web pages. 我使用Google Chrome浏览器及其“ 检查元素 ”之类的开发人员工具来检查网页的性能。 I know that its Developer tool '
Console
' can be used to execute JavaScript. 我知道其开发人员工具“
Console
”可用于执行JavaScript。
I was just saving my one interested web page on my Delicious web account and I noticed that all that information it needs goes through JavaScript
, So I just tried to put that code on my JS Console so that I can see the whole background process, but it failed. 我只是将一个感兴趣的网页保存在Delicious网络帐户中,我注意到它所需的所有信息都通过
JavaScript
传递,所以我只是试图将该代码放在JS控制台中,以便可以看到整个后台过程,但是它失败了。 Can anyone please tell me how should I work with it, because I know this can be done. 谁能告诉我我应该如何使用它,因为我知道这是可以做到的。
The things I am seeing 我看到的东西
The code you will need to save as your bookmark 您将需要保存为书签的代码
javascript:(function(e,t)%7Bvar n=e.document;setTimeout(function()%7Bfunction a(e)%7Bif(e.data==="destroy_bookmarklet")%7Bvar r=n.getElementById(t);if(r)%7Bn.body.removeChild(r);r=null%7D%7D%7Dvar t="DELI_bookmarklet_iframe",r=n.getElementById(t);if(r)%7Breturn%7Dvar i="https://delicious.com/save?",s=n.createElement("iframe");s.id=t;s.src=i+"url="+encodeURIComponent(e.location.href)+"&title="+encodeURIComponent(n.title)+"¬e="+encodeURIComponent(""+(e.getSelection?e.getSelection():n.getSelection?n.getSelection():n.selection.createRange().text))+"&v=1.1";s.style.position="fixed";s.style.top="0";s.style.left="0";s.style.height="100%25";s.style.width="100%25";s.style.zIndex="16777270";s.style.border="none";s.style.visibility="hidden";s.onload=function(){this.style.visibility="visible"};n.body.appendChild(s);var o=e.addEventListener?"addEventListener":"attachEvent";var u=o=="attachEvent"?"onmessage":"message";e[o](u,a,false)},1)})(window)
Details: I've an account on delicious.com which provides me a service to save my interested web links. 详细信息:我在Delicious.com上有一个帐户,该帐户为我提供了保存我感兴趣的Web链接的服务。 for example If I am visiting a Stackoverflow question page and I like the question I just need to click on the bookmark(I've provided you the URL above), I am wondering how it fetches its parent page and saves it in their database, How it can be done using just javascript, I always noticed bookmarks with only web addresses but this one contains javascript code, Can anyone please tell me how it works, Thanks
例如,如果我正在访问Stackoverflow问题页面,而我只需要单击书签(我已经为您提供了上面的URL),我想知道该问题如何获取其父页面并将其保存在他们的数据库中,仅使用javascript即可完成操作,我总是注意到只有网址的书签,但是其中包含javascript代码,谁能告诉我它是如何工作的,谢谢
What you tried to execute is a JavaScript pseudo-scheme
. 您尝试执行的是
JavaScript pseudo-scheme
。 Note the javascript:
part at the beginning. 请注意开头的
javascript:
部分。 Doesn't it sound familiar with other schemes like http:
, https:
, ftp:
? 听起来不熟悉其他方案,例如
http:
, https:
, ftp:
吗?
It would be executed in the URL, not in the Console. 它将在URL中执行,而不是在控制台中执行。 In other words, you use
JavaScript pseudo-scheme
to execute a piece of JavaScript code, in the address bar of the browser . 换句话说,您可以使用
JavaScript pseudo-scheme
在浏览器的地址栏中执行一段JavaScript代码。
To execute it in Console, you have to do two things: 要在控制台中执行它,您必须做两件事:
javascript:
scheme javascript:
scheme %7B
? %7B
吗? It represents {
. {
。 Console won't recognize it, till it's decoded to the original character.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.