简体   繁体   English

从“用户端”运行JavaScript

[英]Running javascript from the “userside”

I have one maybe stupid question but my googling skill were not up to the task. 我可能有一个愚蠢的问题,但我的谷歌搜索技能无法胜任这项任务。

I have some html page that I opet at my work that is php generated. 我有一些html页面,我会在我的工作中使用php生成。 On it 80% of the text is not needed for me so I "made" a javascript code that filters/hides all text I am not interested in. It works just fine but for this to work I must SAVE html document on my computer and insert that javascript code into it so it can make text invisible. 在它上面不需要我80%的文本,因此我“制作”了一个javascript代码,以过滤/隐藏我不感兴趣的所有文本。它工作得很好,但是要正常工作,我必须将html文档保存在计算机上,在其中插入该javascript代码,以使文本不可见。 Now I am thinking of improving this because every time I reload web page on my company's server I need to save it on computer and insert javascript code. 现在,我正在考虑改进此方法,因为每次我在公司服务器上重新加载网页时,都需要将其保存在计算机上并插入javascript代码。 Please point me into the direction that can help me do this. 请指出我可以帮助我完成此操作的方向。 Is there any way to run that javascript code over already opened page in FireFox or some other browsers? 有什么方法可以在FireFox或某些其他浏览器中的已打开页面上运行该javascript代码?

Html page that I am changing is mostly tables and I am hiding rows that I do not need, but there aro around 500 rows and I only need 15 or 20. 我要更改的HTML页面主要是表格,并且隐藏了不需要的行,但是大约有500行,而我只需要15或20行。

Thank for all your effort! 感谢您的所有努力!

Use CSS instead. 改用CSS。 If you have a white background make the text white. 如果背景为白色,则将文本更改为白色。 You can also give visibility: hidden a try. 您还可以提供可视性:隐藏尝试。

One way would be to use a ' bookmarklet '. 一种方法是使用“ bookmarklet ”。 Those are small javascript snippets, which you can insert into your bookmark bar and then execute by clicking on them. 这些是小的javascript代码段,您可以将其插入书签栏,然后单击它们来执行。

<a href="javascript:(function(){alert(1);})()">Drag me to bookmarks for alert</a>

For Example, drag the link in this fiddle into your bookmark bar and it will alert 1 on click. 例如,将此小提琴中的链接拖到书签栏中,它将在单击时提示1。 http://jsfiddle.net/5aAPN/2/ http://jsfiddle.net/5aAPN/2/

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

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