编辑< head> javascript部分 [英] editing the <head> section with javascript

查看:78
本文介绍了编辑< head> javascript部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

页面加载后,我想清除整个head部分.实际上,我的目标是删除head部分中保存的所有JavaScript代码.

I would like to clear the entire head section once the page loads... actually, my goal would be to delete all JavaScript code held in the head section.

有没有办法做这样的事情:

Is there some way to do something like this:

document.head.innerHTML = "";

说明: 我正在使用使用Qt和Webkit拍摄网站快照的Python脚本.
它适用于大多数情况,但有一个失败之处.该站点有很多JavaScript代码,可以在超时时运行. WebKit网页对象允许我在页面上执行JavaScript.如果有某种方法可以让JavaScript从头部分中删除所有代码,我希望可以尝试一下以进行测试,以查看它是否解决了我的屏幕截图脚本问题.

Explanation: I am using a Python script that uses Qt and webkit to take screenshots of websits.
It works on most sties, but there is one that it fails on. That site has a bunch of JavaScript code that it runs on timeouts. The WebKit webpage object allows me to execute JavaScript on the page. If there is some way to have the JavaScript remove all of the code form the head section I'd like to be able to try that for testing purposes to see if it resolves my screenshot script issue.

推荐答案

您可以从头部删除元素,但这无关紧要.脚本已经运行,删除元素不会卸载它们或其他任何东西.

You can remove elements from the head, but it wont matter. The scripts have already run and removing the elements wont unload them or anything.

这篇关于编辑< head> javascript部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆