简体   繁体   English

包含JavaScript的链接URL

[英]Link URL that includes JavaScript

My scenario will involve imgur: In imgur you can link to comments but the display style on the comment chains are all set to display and sometimes the threads expand incredibly large with different branches that aren't relevant to what I want to link to somebody. 我的场景将涉及imgur:在imgur中,您可以链接到注释,但注释链上的显示样式都已设置为显示,有时线程会以与我要链接的对象无关的不同分支极大地扩展。

My question is: Is it possible to link a comment like this 我的问题是:是否可以链接这样的评论

在此处输入图片说明

...and also to have some JavaScript activate that will hide all the child comments? ...并且还需要激活一些JavaScript以隐藏所有子注释?

Usually you just click on the comment or the symbol to the left of it to collapse it but I'm just wondering if there's a way to link so they automatically collapse for the person who receives my link. 通常,您只需单击评论或评论左侧的符号即可将其折叠,但是我只是想知道是否存在链接的方法,以便它们自动为接收我链接的人折叠。

Please don't try to find a solution to my scenario. 请不要尝试为我的情况找到解决方案。 I just need to know how to do something like: 我只需要知道如何做这样的事情:

www.myurl.com/awebpage[javascriptcodethatwillrun]

EDIT: 编辑:

Seeing as this isn't possible I am now wondering if this would be possible: 看到这是不可能的,我现在想知道这是否可能:

JavaScript in the URL bar: URL栏中的JavaScript:

  1. using window.location.href to set the url 使用window.location.href设置网址
  2. run some javascript that will edit the page locally after it loads 运行一些javascript,它将在加载后在本地编辑页面

    javascript:window.location.href=www.myurl.com/webpage;[code for after page loads] javascript:window.location.href = www.myurl.com / webpage; [页面加载后的代码]

Okay, I think I understand what you want. 好吧,我想我知道你想要什么。 You want to be able to automatically run JavaScript on a third party site? 您是否希望能够在第三方站点上自动运行JavaScript?

This you can not do. 这是你做不到的。 One the browser goes to the next page, you can not execute any of your code. 一个浏览器转到下一页,您无法执行任何代码。 Even if you execute the url via JS, your browser will still leave your code, and start executing the code on imgur. 即使您通过JS执行网址,您的浏览器仍然会保留您的代码,并开始在imgur上执行代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM