概念:书签创建标题表单并在提交后再次将其删除

发布于 2024-08-01 23:10:08 字数 1199 浏览 4 评论 0原文

所以我已经思考这个问题有一段时间了,并尝试了各种策略。 基本上,我正在尝试创建一个小书签,当单击该小书签时,会在您碰巧所在的任何页面上弹出标题。 在这个标头中,有一个小表单,其内容被提交到服务器。 提交后,标题应该消失。 在所有情况下,我都用一个简单的加载器书签加载了我的 JS:

javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://localhost/bklts/script.js';})();

问题比听起来更棘手 - 我想出的每个想法在某些情况下都会失败 - 现在让我们忘记 IE 兼容性,我会处理稍后再说。

想法 1 是将浏览器重定向到我的服务器上的页面,其中表单位于顶部,原始页面位于下方的 iframe 内。 这工作得相当好,但非常慢:加载 3 个页面以查看表单和原始页面,然后在提交表单后进行另一个页面加载以返回到原始页面。 此外,它还会破坏框架破坏的网站。

想法 2 是在原始页面的顶部插入一个 iframe,该 iframe src'ing 我的服务器上的表单文档。 这效果非常好,只需要 1 个页面加载(iframe 内容)。 但是,原始页面上绝对放置的元素保留在其绝对位置,覆盖我的标题,而其他所有内容都向下移动。 此外,我发现在提交表单后不可能删除此标头,除非在 iframe 下方创建一个链接,该链接将隐藏 iframe 及其本身,在提交表单后单击该链接。 长话短说,不是真正的生产质量。

想法 3 是根本不使用框架。 在页面顶部插入一个 div,上面有我的表单,该表单将提交到我的服务器。 当然,这样做的问题是原始页面的样式表会影响我的新 div,而且我一生都无法弄清楚如何告诉页面设置 header-div 的样式(或者仅按照我的规则设置样式)。 有人告诉我这在 jQuery 中是微不足道的,虽然我已经开始学习/使用它,但我还没有找到一种方法来做到这一点。 另外还有想法 2 中描述的位置:绝对问题,但我认为这是次要的。

我这样做是不是很愚蠢? 我应该放弃制作标题的所有希望而只是弹出一个新窗口吗? 我真的很希望它成为一个标题,但是如果标题不可能的话,一个窗口就足够了(这是 2009 年 - 这些天几乎没有什么是不可能的......)

无论如何,任何修复帮助以上想法或者全新的想法是非常非常受欢迎的。

非常感谢您抽出时间,

马拉

So I've been pondering this for some time and trying out various strategies. Basically I'm trying to create a bookmarklet that, when clicked, pops up a header on whatever page you happen to be on. In this header, there is a small form, the contents of which are submitted to a server. Once this is submitted, the header should disappear. In all cases, I've loaded my JS with a simple loader bookmarklet:

javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://localhost/bklts/script.js';})();

The problem is tricker than it sounds - every idea i've come up with fails in some instance - and for now lets forget about IE compatibility, I'll deal with that later.

Idea 1 was to redirect the browser to a page on my server with the form at the top and the original page inside an iframe underneath. This works fairly well, but is very slow: 3 page loads to see the form and the original page, followed by another pageload once the form is submitted to return you to the original page. Furthermore, it breaks on sites that framebust.

Idea 2 was to insert an iframe at the top of the original page, the iframe src'ing the form document on my server. This works wonderfully and only requires 1 pageload (the iframe contents). However, absolutely placed elements on the original page remain in their absolute locations, overlaying my header, while everything else is shifted down. Furthermore, I find it is impossible to get rid of this header after the form is submitted short of also creating a link underneath the iframe which would hide the iframe and itself, which one would click after submitting the form. Long story short, not really production quality.

Idea 3 was not to use frames at all. Insert a div at the top of the page with my form on it, and this form would be submitted to my server. The problem with this of course is that the original page's stylesheets will affect my new div, and I can't for the life of me figure out how to tell the page not to style the header-div (or to style it only with my rules). I'm told this is trivial in jQuery, and while I've started learning/using it, I have not found a way to do this. Also there's also the position:absolute problem as described in idea 2, but I figure that's minor.

Am I being stupid in the way i'm going about this? Should I abandon all hope for making a header and just pop up a new window? I'd really like it to be a header, but a window will suffice if a header is impossible (this is 2009 - pretty much nothing is impossible online these days...)

Anyway, any help fixing the above ideas or a completely new idea is very very welcome.

Thanks a lot for your time,

Mala

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

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

发布评论

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

评论(1

一枫情书 2024-08-08 23:10:08

在页面中插入 怎么样?

这应该很简单,并且不会继承原始页面的 CSS。
您可以在查询字符串中传入 iframe 所需的任何内容。

我想让它自毁可能会很棘手......也许您可以将其重定向到原始域上的页面,然后进行轮询。

How about inserting an <iframe> into the page?

That should be simple and won't inherit the original page's CSS.
You can pass in anything you need for the iframe in the querystring.

I suppose making it self-destruct could be tricky... maybe you could redirect it to a page on the original domain, and poll for that.

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