开发者

How can I place a photo on someone else's webpage when linked to from my site?

开发者 https://www.devze.com 2023-03-07 07:01 出处:网络
I know this i开发者_Python百科s a strange thing to want to do, but... How can I place a photo at the top of someone else\'s webpage (\"Page B\") -only- when a visitor links there from my page (\"Page

I know this i开发者_Python百科s a strange thing to want to do, but...

How can I place a photo at the top of someone else's webpage ("Page B") -only- when a visitor links there from my page ("Page A")? I have permission to do this, but with certain limitations: my code needs to be in one location on Page B, and I can't make major changes to Page B. I cannot use Page B's server to run PHP, but I can run PHP on Page A's server.

The photo needs to open automatically with the rest of the Page B, and not require any user input to show up.

This is a unique vendor/retailer situation, so unfortunately I can't provide the urls.

Thanks for any help.


In PHP, you'd do something like:

<?php
if($_SERVER['HTTP_REFERER'] == 'http://www.yoursite.com/referringpage.html')
{
    printf('<img src="yourbutton.png">');
}
?>

Which is very limited because:

  • It will only work for a referring single page (referringpage.html) and not otherreferringpage.html
  • It will only work for a single landing page. If the user navigates off of the page, then back (not through browser's back), the button will not show up.

To solve the first you could do a substring of the referrer, e.g.

<?php
if(substring($_SERVER['HTTP_REFERER'],0,24) == 'http://www.yoursite.com/')
{
    printf('<img src="yourbutton.png">');
}
?>

To solve the second you could set session variables (except then you'd need access to the very top of the "outermost" page -- which doesn't sound like an option.)


Depends on the design of the page. Lets say,

  1. If the page is divided into frames, then you can use iframe.
  2. if It's a single page, try have a separation with div tag. Insert the html into Div Tag.

If the above two points won't help you,give an idea of how the page is designed


I think a simple answer would be to write a html page (lets call it linkPage) that has the image/text/div or whatever you want to display on the top and then include an iframe that would cover the rest of the page using css. You could pass the page you are linking to as a GET or POST parameter to the linkPage and then set the src of the iframe to that url.

There are probably other ways of doing this that are more complicated / seamless but this would be the easiest, quickest way to get it done.

0

精彩评论

暂无评论...
验证码 换一张
取 消