使用 PHP 检测链接何时被点击
我已经构建了一个浏览器引擎,可以在不执行服务器端脚本的情况下检索页面......我知道这似乎很荒谬,但我正在将其作为学校项目的一部分。
我遇到的问题是,一旦显示页面,如果单击链接,它会将您带到 www.their-site.com 而不是 www.my-site.com?site=www.their-site.com。
基本上我需要我的 php 页面来检测链接是否被单击,如果是,则添加“www.my-site.com?”在它之前,以便所有站点仍将在没有所有服务器端脚本的情况下呈现。他们有办法做到这一点吗?
- - - - - - - -编辑 - - - - - - - - - - - - - - - - - --------------------------------------
好吧,我想我还不够清楚第一次这么抱歉。
我制作了一个 php 页面,它将显示任何站点的内容,而无需执行属于该页面的服务器端脚本。这使您可以绕过那些烦人的新闻文章,让您可以浏览它们两秒钟,然后出现一个登录框。问题是一旦您访问了这些页面,如果您单击任何链接,您就会连接到他们的服务器并且脚本会重新打开。我希望执行我的 php,而不是他们的
I have built an in browser engine that will retrieve pages without executing server side scripting... seems ridiculous, I know, but I'm doing this as part of a school project.
The problem that I am having is that once it displays the page if a link is clicked it will bring you to www.their-site.com instead of www.my-site.com?site=www.their-site.com.
Basically I need my php page to detect if a link is clicked and, if so, add "www.my-site.com?" before it so that all sites will still be rendered without all the server side scripting. Is their any way to do this?
---------------EDIT---------------------------------------------------------------------------
Ok I guess I wasn't clear enough the first time sorry about that.
I have made a php page that will display the contents of any site without executing the server side scripting that belongs with that page. This allows you to get around those annoying news articles that allow you to have a glimpse at them for two seconds and then a login box appears. the problem is once you've accessed the pages if you click any links you are connected to their server and the scripts turn back on. I want MY php to execute, not THEIRS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你首先需要知道自己想要什么。
你说没有服务器端脚本,然后你提到了 php。
要做到这一点,我认为你不能只用 js 来完成。
您需要使用 php 获取页面,具体取决于具体内容,修改它们,以便单击链接时,它会向另一个页面发送 ajax 调用。这将需要替换正则表达式或使用 htmldom。
单击链接时,它应该将 ajax 响应发送到 php 页面,然后该 php 页面可以请求该页面,进行修改并将其发送回浏览器。然后就可以用js来替换页面内容了。
You need to know what you want first.
You say no server side scripting, then you mention php.
To do this, I don't think you can do it with just js.
You need to get the pages, using php, depending on what exactly, modify them such that when a link is clicked, it sends an ajax call to another page. This will require either regex replacement or the use of htmldom.
When a link is clicked, it should send the ajax response to the php page which can then request tha page, make modifications and send it back to the browser. You can then use js to replace the page contents.