获取php页面的url

发布于 2024-11-05 06:09:51 字数 239 浏览 0 评论 0原文

我正在开发“通过电子邮件发送此页面”弹出页面。我想将基本页面的网址作为电子邮件发送,但它应该是一个弹出窗口。

我使用过HTTP_REFERER,它在 Firefox 上运行良好,但在 Internet Explorer 上运行不正常。

我正在获取当前页面的 url,但我希望在新的弹出窗口页面中显示该 url。

除了 HTTP_REFERER 之外还有其他选择吗?

I am working on "Email this page" Popup page. I want to send url of base page as an email, but it should be a popup window.

I have used HTTP_REFERER, it is working fine on Firefox, but not working on Internet Explorer.

I am getting the url of current page but I want that url in new popup window page.

Is there any alternative than HTTP_REFERER.

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

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

发布评论

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

评论(3

゛清羽墨安 2024-11-12 06:09:51

在您想要获取 URL 的页面上,您可以使用 $_SERVER['REQUEST_URI'] 来获取请求的 URI(除了方案和主机名;换句话说,您可以获得路径和查询字符串)。使用查询字符串或会话将其传递到您的其他页面。前者是更好的选择,因为后者不是 RESTful。有时可能可以打破 REST 针对服务器端状态的规则,但这可能不是这样。

On the page you wish to grab the URL of, you can use $_SERVER['REQUEST_URI'] to get the requested URI (except the scheme & hostname; in other words, you get the path and query string). Pass this to your other page either using a query string or sessions. The former is preferable, as the latter isn't RESTful. There may be times when it's OK to break REST's rule against server side state, but this probably isn't it.

白龙吟 2024-11-12 06:09:51

没有办法,除非你自己保管或者寄过来。 页面有一个如何做到这一点的示例,但前提是您事先进行了设置。如果该网站是您自己的,那么您应该没问题。如果没有,那么你就会挣扎。

There is no way unless you store it or send it yourself. This page has one example of how to do it, but only really if you set it beforehand. If the site is your own then you should be ok. If not then you will struggle.

她说她爱他 2024-11-12 06:09:51

发生这种情况是因为 HTTP_REFERER 是由客户端浏览器发送的,这意味着它的值可以完全操纵,甚至可以为 null。这意味着这个变量不是很可靠。但如果该网站是您的,还有其他解决方案。

您可以通过 QueryStrings 发送 url 或任何其他标识(例如 ID)。因此,您将获得如下所示的链接 URL the_send_page_name.php?ref=index.php

请注意,此方法仅在您在自己的网站中打开弹出窗口时才有效。

That happens because the HTTP_REFERER is sent by the client browser, which means that it's value can be totally manipulated or can even be null. This means that this variable isn't very reliable. But if the site is yours, there are other solutions.

You can send the url or any other identification like an ID by QueryStrings. So you'll have the link URL like this the_send_page_name.php?ref=index.php

Be aware that this method only works if you're opening the Pop-up in a site that's yours.

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